Skip to content

Commit 5d9b9e1

Browse files
authored
Merge pull request #82 from ipfs/asr/deps
Add contexts to IpldBlockstore
2 parents 79ee2f1 + 0412412 commit 5d9b9e1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

store.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ type IpldStore interface {
2222
// IpldBlockstore defines a subset of the go-ipfs-blockstore Blockstore interface providing methods
2323
// for storing and retrieving block-centered data.
2424
type IpldBlockstore interface {
25-
Get(cid.Cid) (block.Block, error)
26-
Put(block.Block) error
25+
Get(context.Context, cid.Cid) (block.Block, error)
26+
Put(context.Context, block.Block) error
2727
}
2828

2929
// IpldBlockstoreViewer is a trait that enables zero-copy access to blocks in
@@ -60,7 +60,7 @@ func (s *BasicIpldStore) Get(ctx context.Context, c cid.Cid, out interface{}) er
6060
})
6161
}
6262

63-
blk, err := s.Blocks.Get(c)
63+
blk, err := s.Blocks.Get(ctx, c)
6464
if err != nil {
6565
return err
6666
}
@@ -125,7 +125,7 @@ func (s *BasicIpldStore) Put(ctx context.Context, v interface{}) (cid.Cid, error
125125
return cid.Undef, err
126126
}
127127

128-
if err := s.Blocks.Put(blk); err != nil {
128+
if err := s.Blocks.Put(ctx, blk); err != nil {
129129
return cid.Undef, err
130130
}
131131

@@ -142,7 +142,7 @@ func (s *BasicIpldStore) Put(ctx context.Context, v interface{}) (cid.Cid, error
142142
return cid.Undef, err
143143
}
144144

145-
if err := s.Blocks.Put(nd); err != nil {
145+
if err := s.Blocks.Put(ctx, nd); err != nil {
146146
return cid.Undef, err
147147
}
148148

@@ -187,15 +187,15 @@ func newMockBlocks() *mockBlocks {
187187
return &mockBlocks{make(map[cid.Cid]block.Block)}
188188
}
189189

190-
func (mb *mockBlocks) Get(c cid.Cid) (block.Block, error) {
190+
func (mb *mockBlocks) Get(ctx context.Context, c cid.Cid) (block.Block, error) {
191191
d, ok := mb.data[c]
192192
if ok {
193193
return d, nil
194194
}
195195
return nil, fmt.Errorf("not found %s", c)
196196
}
197197

198-
func (mb *mockBlocks) Put(b block.Block) error {
198+
func (mb *mockBlocks) Put(ctx context.Context, b block.Block) error {
199199
mb.data[b.Cid()] = b
200200
return nil
201201
}

0 commit comments

Comments
 (0)