Skip to content

Commit 0d481da

Browse files
committed
Add context to DAGSyncer interface
This allows out-of-the-box compatibility with latest version of ipfs-lite.
1 parent 1c00690 commit 0d481da

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crdt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type DAGSyncer interface {
6666
ipld.DAGService
6767
// Returns true if the block is locally available (therefore, it
6868
// is considered processed).
69-
HasBlock(c cid.Cid) (bool, error)
69+
HasBlock(ctx context.Context, c cid.Cid) (bool, error)
7070
}
7171

7272
// A SessionDAGSyncer is a Sessions-enabled DAGSyncer. This type of DAG-Syncer
@@ -445,7 +445,7 @@ func (store *Datastore) handleBlock(c cid.Cid) error {
445445
// Ignore already known blocks.
446446
// This includes the case when the block is a current
447447
// head.
448-
known, err := store.dagSyncer.HasBlock(c)
448+
known, err := store.dagSyncer.HasBlock(store.ctx, c)
449449
if err != nil {
450450
return errors.Wrap(err, "error checking for known block")
451451
}
@@ -607,7 +607,7 @@ func (store *Datastore) processNode(ng *crdtNodeGetter, root cid.Cid, rootPrio u
607607
continue
608608
}
609609

610-
known, err := store.dagSyncer.HasBlock(child)
610+
known, err := store.dagSyncer.HasBlock(store.ctx, child)
611611
if err != nil {
612612
return nil, errors.Wrapf(err, "error checking for known block %s", child)
613613
}

crdt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ type mockDAGSync struct {
166166
knownBlocks map[cid.Cid]struct{}
167167
}
168168

169-
func (mds *mockDAGSync) HasBlock(c cid.Cid) (bool, error) {
169+
func (mds *mockDAGSync) HasBlock(ctx context.Context, c cid.Cid) (bool, error) {
170170
mds.knownBlocksMux.RLock()
171171
_, ok := mds.knownBlocks[c]
172172
mds.knownBlocksMux.RUnlock()

0 commit comments

Comments
 (0)