Skip to content

Commit

Permalink
upgrade github.com/ipfs/go-datastore to v0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ta0li committed Jan 4, 2022
1 parent da83d71 commit 8c4dcce
Show file tree
Hide file tree
Showing 115 changed files with 1,413 additions and 1,272 deletions.
2 changes: 1 addition & 1 deletion app/client/apiface/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type INetwork interface {
// Rule[perm:read]
NetworkFindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo
// Rule[perm:read]
NetworkGetClosestPeers(ctx context.Context, key string) (<-chan peer.ID, error)
NetworkGetClosestPeers(ctx context.Context, key string) ([]peer.ID, error)
// Rule[perm:read]
NetworkFindPeer(ctx context.Context, peerID peer.ID) (peer.AddrInfo, error)
// Rule[perm:read]
Expand Down
2 changes: 1 addition & 1 deletion app/client/apiface/v0api/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type INetwork interface {
// Rule[perm:read]
NetworkFindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo
// Rule[perm:admin]
NetworkGetClosestPeers(ctx context.Context, key string) (<-chan peer.ID, error)
NetworkGetClosestPeers(ctx context.Context, key string) ([]peer.ID, error)
// Rule[perm:read]
NetworkFindPeer(ctx context.Context, peerID peer.ID) (peer.AddrInfo, error)
// Rule[perm:read]
Expand Down
4 changes: 2 additions & 2 deletions app/client/v0api/full.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions app/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"context"
"time"

chain2 "github.com/filecoin-project/venus/pkg/chain"
"github.com/filecoin-project/venus/pkg/jwtauth"
"github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl"
types "github.com/filecoin-project/venus/venus-shared/chain"
"github.com/ipfs-force-community/metrics/ratelimit"
logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p"
"github.com/pkg/errors"
"golang.org/x/xerrors"

"github.com/ipfs-force-community/metrics/ratelimit"

"github.com/filecoin-project/venus/app/submodule/blockstore"
"github.com/filecoin-project/venus/app/submodule/chain"
config2 "github.com/filecoin-project/venus/app/submodule/config"
Expand All @@ -26,13 +25,15 @@ import (
"github.com/filecoin-project/venus/app/submodule/storagenetworking"
"github.com/filecoin-project/venus/app/submodule/syncer"
"github.com/filecoin-project/venus/app/submodule/wallet"
chain2 "github.com/filecoin-project/venus/pkg/chain"
"github.com/filecoin-project/venus/pkg/clock"
"github.com/filecoin-project/venus/pkg/journal"
"github.com/filecoin-project/venus/pkg/jwtauth"
"github.com/filecoin-project/venus/pkg/paychmgr"
"github.com/filecoin-project/venus/pkg/repo"
"github.com/filecoin-project/venus/pkg/util/ffiwrapper"
"github.com/libp2p/go-libp2p"
"github.com/pkg/errors"
"github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl"
types "github.com/filecoin-project/venus/venus-shared/chain"
)

// Builder is a helper to aid in the construction of a filecoin node.
Expand Down Expand Up @@ -84,7 +85,7 @@ func (b *Builder) build(ctx context.Context) (*Node, error) {
}

// fetch genesis block id
b.genBlk, err = readGenesisCid(b.repo.ChainDatastore(), b.repo.Datastore())
b.genBlk, err = readGenesisCid(ctx, b.repo.ChainDatastore(), b.repo.Datastore())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -143,7 +144,7 @@ func (b *Builder) build(ctx context.Context) (*Node, error) {
return nil, errors.Wrap(err, "failed to build node.wallet")
}

nd.mpool, err = mpool.NewMpoolSubmodule((*builder)(b), nd.network, nd.chain, nd.wallet)
nd.mpool, err = mpool.NewMpoolSubmodule(ctx, (*builder)(b), nd.network, nd.chain, nd.wallet)
if err != nil {
return nil, errors.Wrap(err, "failed to build node.mpool")
}
Expand Down
7 changes: 4 additions & 3 deletions app/node/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package node

import (
"bytes"
"context"
"encoding/json"

"github.com/ipfs/go-cid"
Expand All @@ -15,8 +16,8 @@ import (

// readGenesisCid is a helper function that queries the provided datastore for
// an entry with the genesisKey cid, returning if found.
func readGenesisCid(chainDs datastore.Datastore, bs blockstoreutil.Blockstore) (types.BlockHeader, error) {
bb, err := chainDs.Get(chain.GenesisKey)
func readGenesisCid(ctx context.Context, chainDs datastore.Datastore, bs blockstoreutil.Blockstore) (types.BlockHeader, error) {
bb, err := chainDs.Get(ctx, chain.GenesisKey)
if err != nil {
return types.BlockHeader{}, errors.Wrap(err, "failed to read genesisKey")
}
Expand All @@ -27,7 +28,7 @@ func readGenesisCid(chainDs datastore.Datastore, bs blockstoreutil.Blockstore) (
return types.BlockHeader{}, errors.Wrap(err, "failed to cast genesisCid")
}

blkRawData, err := bs.Get(c)
blkRawData, err := bs.Get(ctx, c)
if err != nil {
return types.BlockHeader{}, errors.Wrap(err, "failed to read genesis block")
}
Expand Down
2 changes: 1 addition & 1 deletion app/node/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func initPeerKey(store fskeystore.Keystore, key acrypto.PrivKey) error {
return errors.Wrap(err, "failed to create peer key")
}
}
data, err := key.Bytes()
data, err := key.Raw() // TODO ?
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (node *Node) Start(ctx context.Context) error {
return err
}

err = node.paychan.Start()
err = node.paychan.Start(ctx)
if err != nil {
return err
}
Expand Down
18 changes: 9 additions & 9 deletions app/node/test/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import (
"math/rand"
"testing"

"github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl"
types "github.com/filecoin-project/venus/venus-shared/chain"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/pkg/util/blockstoreutil"
ds "github.com/ipfs/go-datastore"
blockstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/fixtures/fortest"
"github.com/filecoin-project/venus/pkg/config"
"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/pkg/util/blockstoreutil"
"github.com/filecoin-project/venus/pkg/util/ffiwrapper/impl"
"github.com/filecoin-project/venus/pkg/wallet"
gengen "github.com/filecoin-project/venus/tools/gengen/util"
types "github.com/filecoin-project/venus/venus-shared/chain"
)

// ChainSeed is a generalized struct for configuring node
Expand Down Expand Up @@ -63,15 +63,15 @@ func (cs *ChainSeed) GenesisInitFunc(cst cbor.IpldStore, bs blockstore.Blockstor
}

// GiveKey gives the given key to the given node
func (cs *ChainSeed) GiveKey(t *testing.T, nd *node.Node, key int) address.Address {
func (cs *ChainSeed) GiveKey(ctx context.Context,t *testing.T, nd *node.Node, key int) address.Address {
t.Helper()
bcks := nd.Wallet().Wallet.Backends(wallet.DSBackendType)
require.Len(t, bcks, 1, "expected to get exactly one datastore backend")

dsb := bcks[0].(*wallet.DSBackend)
_ = dsb.SetPassword(wallet.TestPassword)
_ = dsb.SetPassword(ctx, wallet.TestPassword)
kinfo := cs.info.Keys[key]
require.NoError(t, dsb.ImportKey(kinfo))
require.NoError(t, dsb.ImportKey(ctx, kinfo))

addr, err := kinfo.Address()
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions app/submodule/blockstore/blockstore_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type blockstoreAPI struct { //nolint
}

func (blockstoreAPI *blockstoreAPI) ChainReadObj(ctx context.Context, ocid cid.Cid) ([]byte, error) {
blk, err := blockstoreAPI.blockstore.Blockstore.Get(ocid)
blk, err := blockstoreAPI.blockstore.Blockstore.Get(ctx, ocid)
if err != nil {
return nil, xerrors.Errorf("blockstore get: %w", err)
}
Expand All @@ -31,11 +31,11 @@ func (blockstoreAPI *blockstoreAPI) ChainReadObj(ctx context.Context, ocid cid.C
}

func (blockstoreAPI *blockstoreAPI) ChainDeleteObj(ctx context.Context, obj cid.Cid) error {
return blockstoreAPI.blockstore.Blockstore.DeleteBlock(obj)
return blockstoreAPI.blockstore.Blockstore.DeleteBlock(ctx, obj)
}

func (blockstoreAPI *blockstoreAPI) ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error) {
return blockstoreAPI.blockstore.Blockstore.Has(obj)
return blockstoreAPI.blockstore.Blockstore.Has(ctx, obj)
}

func (blockstoreAPI *blockstoreAPI) ChainStatObj(ctx context.Context, obj cid.Cid, base cid.Cid) (apitypes.ObjStat, error) {
Expand Down
2 changes: 1 addition & 1 deletion app/submodule/chain/account_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewAccountAPI(chain *ChainSubmodule) v1api.IAccount {

// StateAccountKey returns the public key address of the given ID address
func (accountAPI *accountAPI) StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {
ts, err := accountAPI.chain.ChainReader.GetTipSet(tsk)
ts, err := accountAPI.chain.ChainReader.GetTipSet(ctx, tsk)
if err != nil {
return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err)
}
Expand Down
18 changes: 9 additions & 9 deletions app/submodule/chain/apibstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,40 @@ func NewAPIBlockstore(cio ChainIO) blockstore.Blockstore {
}

// DeleteBlock implements Blockstore.DeleteBlock.
func (a *apiBStore) DeleteBlock(cid.Cid) error {
func (a *apiBStore) DeleteBlock(context.Context, cid.Cid) error {
return xerrors.New("not supported")
}

// Has implements Blockstore.Has.
func (a *apiBStore) Has(c cid.Cid) (bool, error) {
return a.api.ChainHasObj(context.TODO(), c)
func (a *apiBStore) Has(ctx context.Context, c cid.Cid) (bool, error) {
return a.api.ChainHasObj(ctx, c)
}

// Get implements Blockstore.Get.
func (a *apiBStore) Get(c cid.Cid) (blocks.Block, error) {
bb, err := a.api.ChainReadObj(context.TODO(), c)
func (a *apiBStore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error) {
bb, err := a.api.ChainReadObj(ctx, c)
if err != nil {
return nil, err
}
return blocks.NewBlockWithCid(bb, c)
}

// GetSize implements Blockstore.GetSize.
func (a *apiBStore) GetSize(c cid.Cid) (int, error) {
bb, err := a.api.ChainReadObj(context.TODO(), c)
func (a *apiBStore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
bb, err := a.api.ChainReadObj(ctx, c)
if err != nil {
return 0, err
}
return len(bb), nil
}

// Put implements Blockstore.Put.
func (a *apiBStore) Put(blocks.Block) error {
func (a *apiBStore) Put(context.Context, blocks.Block) error {
return xerrors.New("not supported")
}

// PutMany implements Blockstore.PutMany.
func (a *apiBStore) PutMany([]blocks.Block) error {
func (a *apiBStore) PutMany(context.Context, []blocks.Block) error {
return xerrors.New("not supported")
}

Expand Down
Loading

0 comments on commit 8c4dcce

Please sign in to comment.