Skip to content

Commit

Permalink
Fix p2p side
Browse files Browse the repository at this point in the history
  • Loading branch information
islamaliev committed Jun 21, 2024
1 parent 95b9102 commit 43b83e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
5 changes: 4 additions & 1 deletion internal/db/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (db *db) handleMerges(ctx context.Context, sub *event.Subscription) {

// retry the merge process if a conflict occurs
//
// conficts occur when a user updates a document
// conflicts occur when a user updates a document
// while a merge is in progress.
var err error
for i := 0; i < db.MaxTxnRetries(); i++ {
Expand Down Expand Up @@ -273,6 +273,9 @@ func (mp *mergeProcessor) loadComposites(
func (mp *mergeProcessor) mergeComposites(ctx context.Context) error {
for e := mp.composites.Front(); e != nil; e = e.Next() {
block := e.Value.(*coreblock.Block)
if block.IsEncrypted != nil && *block.IsEncrypted {
continue
}
link, err := block.GenerateLink()
if err != nil {
return err
Expand Down
7 changes: 3 additions & 4 deletions internal/merkle/clock/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ var (
type MerkleClock struct {
headstore datastore.DSReaderWriter
dagstore datastore.DAGStore
// dagSyncer
headset *heads
crdt core.ReplicatedData
headset *heads
crdt core.ReplicatedData
}

// NewMerkleClock returns a new MerkleClock.
Expand Down Expand Up @@ -118,7 +117,7 @@ func (mc *MerkleClock) AddDelta(
return cidlink.Link{}, nil, err
}

b, err := block.Marshal()
b, err := dagBlock.Marshal()
if err != nil {
return cidlink.Link{}, nil, err
}
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/encryption/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestDocEncryption_ShouldStoreCommitsDeltaEncrypted(t *testing.T) {
`,
Results: []map[string]any{
{
"cid": "bafyreidrbl46bz5nuzuby6s4zqvzliq4gyup3pq6ipy7ljm5o7l5hxtjhm",
"cid": "bafyreih7ry7ef26xn3lm2rhxusf2rbgyvl535tltrt6ehpwtvdnhlmptiu",
"collectionID": int64(1),
"delta": encrypt(testUtils.CBORValue(21)),
"docID": "bae-c9fb0fa4-1195-589c-aa54-e68333fb90b3",
Expand All @@ -63,7 +63,7 @@ func TestDocEncryption_ShouldStoreCommitsDeltaEncrypted(t *testing.T) {
"links": []map[string]any{},
},
{
"cid": "bafyreighzsctnwzhw57nbzici6dbvohozwet5w2baey3p4dxtxp7wxybui",
"cid": "bafyreifusejlwidaqswasct37eorazlfix6vyyn5af42pmjvktilzj5cty",
"collectionID": int64(1),
"delta": encrypt(testUtils.CBORValue("John")),
"docID": "bae-c9fb0fa4-1195-589c-aa54-e68333fb90b3",
Expand All @@ -73,7 +73,7 @@ func TestDocEncryption_ShouldStoreCommitsDeltaEncrypted(t *testing.T) {
"links": []map[string]any{},
},
{
"cid": "bafyreidzfgvlx6eaj4furwl3mpvxp3wslbvzs4hvknivhpjw7g275k5v5i",
"cid": "bafyreicvxlfxeqghmc3gy56rp5rzfejnbng4nu77x5e3wjinfydl6wvycq",
"collectionID": int64(1),
"delta": nil,
"docID": "bae-c9fb0fa4-1195-589c-aa54-e68333fb90b3",
Expand All @@ -82,12 +82,12 @@ func TestDocEncryption_ShouldStoreCommitsDeltaEncrypted(t *testing.T) {
"height": int64(1),
"links": []map[string]any{
{
"cid": "bafyreidrbl46bz5nuzuby6s4zqvzliq4gyup3pq6ipy7ljm5o7l5hxtjhm",
"name": "age",
"cid": "bafyreifusejlwidaqswasct37eorazlfix6vyyn5af42pmjvktilzj5cty",
"name": "name",
},
{
"cid": "bafyreighzsctnwzhw57nbzici6dbvohozwet5w2baey3p4dxtxp7wxybui",
"name": "name",
"cid": "bafyreih7ry7ef26xn3lm2rhxusf2rbgyvl535tltrt6ehpwtvdnhlmptiu",
"name": "age",
},
},
},
Expand Down

0 comments on commit 43b83e8

Please sign in to comment.