Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow initial RecordsWrite without data to be written to the DWN. #629

Merged
merged 9 commits into from
Dec 1, 2023

Conversation

LiranCohen
Copy link
Member

@LiranCohen LiranCohen commented Nov 28, 2023

There are some cases where a DWN might have an initial RecordsWrite message used to create a record, but not have the data associated with it.

Until now this was only possible through a special method on the DWN synchronizePrunedInitialRecordsWrite which was only used for sync. However, there are multi-participant scenarios where this same behavior is necessary.

This PR exposes that functionality to the general processing of RecordsWrite messages.

If a RecordsWrite message is supplied without any data, it is checked that it is the initial RecordsWrite and indexes it as not being the latest state, this prevents it from being queryable without any data until a subsequent RecordsWrite with data is available.

Addresses: #628

Copy link

codesandbox bot commented Nov 28, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (066e74b) 98.57% compared to head (e57db06) 98.42%.

Files Patch % Lines
src/handlers/records-write.ts 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #629      +/-   ##
==========================================
- Coverage   98.57%   98.42%   -0.15%     
==========================================
  Files          68       68              
  Lines        8417     8402      -15     
  Branches     1227     1227              
==========================================
- Hits         8297     8270      -27     
- Misses        114      124      +10     
- Partials        6        8       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LiranCohen LiranCohen marked this pull request as ready for review November 30, 2023 17:31
Copy link
Contributor

@thehenrytsai thehenrytsai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments, and sent a PR to address some of the comments:
#635

src/handlers/records-write.ts Outdated Show resolved Hide resolved
src/handlers/records-write.ts Outdated Show resolved Hide resolved
src/handlers/records-write.ts Outdated Show resolved Hide resolved
src/handlers/records-write.ts Outdated Show resolved Hide resolved
src/handlers/records-write.ts Outdated Show resolved Hide resolved
@LiranCohen LiranCohen force-pushed the lirancohen/write-initial-without-data branch from 597d40b to ab170bf Compare December 1, 2023 15:17
@LiranCohen
Copy link
Member Author

Love the refactor and comments, having the isLatestBaseState within the methods was definitely more opaque, so I like this approach much better.

Copy link
Contributor

@thehenrytsai thehenrytsai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 💯

@LiranCohen LiranCohen merged commit 9c0fdb5 into main Dec 1, 2023
4 checks passed
@LiranCohen LiranCohen deleted the lirancohen/write-initial-without-data branch December 1, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants