Skip to content

Commit

Permalink
Update to context datastores (#653)
Browse files Browse the repository at this point in the history
* Update to context datastores
  • Loading branch information
arajasek authored Dec 11, 2021
1 parent 5d6c469 commit e111ec2
Show file tree
Hide file tree
Showing 23 changed files with 482 additions and 282 deletions.
10 changes: 5 additions & 5 deletions discovery/impl/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func (l *Local) OnReady(ready shared.ReadyFunc) {
l.readySub.Subscribe(ready)
}

func (l *Local) AddPeer(cid cid.Cid, peer retrievalmarket.RetrievalPeer) error {
func (l *Local) AddPeer(ctx context.Context, cid cid.Cid, peer retrievalmarket.RetrievalPeer) error {
key := dshelp.MultihashToDsKey(cid.Hash())
exists, err := l.ds.Has(key)
exists, err := l.ds.Has(ctx, key)
if err != nil {
return err
}
Expand All @@ -73,7 +73,7 @@ func (l *Local) AddPeer(cid cid.Cid, peer retrievalmarket.RetrievalPeer) error {
return err
}
} else {
entry, err := l.ds.Get(key)
entry, err := l.ds.Get(ctx, key)
if err != nil {
return err
}
Expand All @@ -91,7 +91,7 @@ func (l *Local) AddPeer(cid cid.Cid, peer retrievalmarket.RetrievalPeer) error {
}
}

return l.ds.Put(key, newRecord.Bytes())
return l.ds.Put(ctx, key, newRecord.Bytes())
}

func hasPeer(peerList discovery.RetrievalPeers, peer retrievalmarket.RetrievalPeer) bool {
Expand All @@ -104,7 +104,7 @@ func hasPeer(peerList discovery.RetrievalPeers, peer retrievalmarket.RetrievalPe
}

func (l *Local) GetPeers(payloadCID cid.Cid) ([]retrievalmarket.RetrievalPeer, error) {
entry, err := l.ds.Get(dshelp.MultihashToDsKey(payloadCID.Hash()))
entry, err := l.ds.Get(context.TODO(), dshelp.MultihashToDsKey(payloadCID.Hash()))
if err == datastore.ErrNotFound {
return []retrievalmarket.RetrievalPeer{}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions discovery/impl/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestLocal_AddPeer(t *testing.T) {

payloadCID := shared_testutil.GenerateCids(1)[0]
for _, testpeer := range tc.peers2add {
require.NoError(t, l.AddPeer(payloadCID, testpeer))
require.NoError(t, l.AddPeer(ctx, payloadCID, testpeer))
}
actualPeers, err := l.GetPeers(payloadCID)
require.NoError(t, err)
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestLocalMigrations(t *testing.T) {
buf := new(bytes.Buffer)
err := rps.MarshalCBOR(buf)
require.NoError(t, err)
err = ds.Put(dshelp.MultihashToDsKey(c.Hash()), buf.Bytes())
err = ds.Put(ctx, dshelp.MultihashToDsKey(c.Hash()), buf.Bytes())
require.NoError(t, err)
}

Expand Down
44 changes: 22 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,58 @@ module github.com/filecoin-project/go-fil-markets
go 1.13

require (
github.com/filecoin-project/dagstore v0.4.2
github.com/filecoin-project/dagstore v0.4.3-0.20211211192320-72b849e131d2
github.com/filecoin-project/go-address v0.0.5
github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2
github.com/filecoin-project/go-commp-utils v0.1.1-0.20210427191551-70bf140d31c7
github.com/filecoin-project/go-data-transfer v1.11.4
github.com/filecoin-project/go-ds-versioning v0.1.0
github.com/filecoin-project/go-commp-utils v0.1.3
github.com/filecoin-project/go-data-transfer v1.12.0
github.com/filecoin-project/go-ds-versioning v0.0.0-20211206185234-508abd7c2aff
github.com/filecoin-project/go-fil-commcid v0.1.0
github.com/filecoin-project/go-fil-commp-hashhash v0.1.0
github.com/filecoin-project/go-padreader v0.0.0-20210723183308-812a16dc01b1
github.com/filecoin-project/go-state-types v0.1.1-0.20210506134452-99b279731c48
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe
github.com/filecoin-project/go-statestore v0.1.1
github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/specs-actors v0.9.13
github.com/filecoin-project/specs-actors/v2 v2.3.5-0.20210114162132-5b58b773f4fb
github.com/hannahhoward/cbor-gen-for v0.0.0-20200817222906-ea96cece81f1
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-blockservice v0.1.5
github.com/ipfs/go-cid v0.0.8-0.20210716091050-de6c03deae1c
github.com/ipfs/go-blockservice v0.2.1
github.com/ipfs/go-cid v0.1.0
github.com/ipfs/go-cidutil v0.0.2
github.com/ipfs/go-datastore v0.4.5
github.com/ipfs/go-filestore v1.0.0
github.com/ipfs/go-graphsync v0.10.0
github.com/ipfs/go-ipfs-blockstore v1.0.4
github.com/ipfs/go-datastore v0.5.1
github.com/ipfs/go-filestore v1.1.0
github.com/ipfs/go-graphsync v0.11.0
github.com/ipfs/go-ipfs-blockstore v1.1.2
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-ipfs-chunker v0.0.5
github.com/ipfs/go-ipfs-ds-help v1.0.0
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
github.com/ipfs/go-ipfs-ds-help v1.1.0
github.com/ipfs/go-ipfs-exchange-offline v0.1.1
github.com/ipfs/go-ipfs-files v0.0.8
github.com/ipfs/go-ipld-cbor v0.0.5
github.com/ipfs/go-ipld-format v0.2.0
github.com/ipfs/go-log/v2 v2.3.0
github.com/ipfs/go-merkledag v0.3.2
github.com/ipfs/go-merkledag v0.5.1
github.com/ipfs/go-unixfs v0.2.6
github.com/ipld/go-car v0.3.2-0.20211001225732-32d0d9933823
github.com/ipld/go-car/v2 v2.1.0
github.com/ipld/go-ipld-prime v0.12.3
github.com/ipld/go-car v0.3.3-0.20211210032800-e6f244225a16
github.com/ipld/go-car/v2 v2.1.1-0.20211211000942-be2525f6bf2d
github.com/ipld/go-ipld-prime v0.14.3-0.20211207234443-319145880958
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/jpillora/backoff v1.0.0
github.com/libp2p/go-libp2p v0.14.0
github.com/libp2p/go-libp2p-core v0.8.5
github.com/multiformats/go-multiaddr v0.3.1
github.com/libp2p/go-libp2p v0.16.0
github.com/libp2p/go-libp2p-core v0.11.0
github.com/multiformats/go-multiaddr v0.4.0
github.com/multiformats/go-multibase v0.0.3
github.com/multiformats/go-multicodec v0.3.1-0.20210902112759-1539a079fd61
github.com/multiformats/go-multihash v0.0.15
github.com/multiformats/go-multihash v0.1.0
github.com/multiformats/go-varint v0.0.6
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9
github.com/stretchr/testify v1.7.0
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11
github.com/whyrusleeping/cbor-gen v0.0.0-20210713220151-be142a5ae1a8
golang.org/x/exp v0.0.0-20210715201039-d37aa40e8013
golang.org/x/net v0.0.0-20210423184538-5f58ad60dda6
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
)

Expand Down
Loading

0 comments on commit e111ec2

Please sign in to comment.