Add graphsync
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
d68041c394
commit
8af80169c0
@ -91,6 +91,7 @@ const (
|
|||||||
|
|
||||||
RunHelloKey
|
RunHelloKey
|
||||||
RunBlockSyncKey
|
RunBlockSyncKey
|
||||||
|
RunChainGraphsync
|
||||||
RunPeerMgrKey
|
RunPeerMgrKey
|
||||||
|
|
||||||
HandleIncomingBlocksKey
|
HandleIncomingBlocksKey
|
||||||
@ -227,6 +228,7 @@ func Online() Option {
|
|||||||
|
|
||||||
Override(RunHelloKey, modules.RunHello),
|
Override(RunHelloKey, modules.RunHello),
|
||||||
Override(RunBlockSyncKey, modules.RunBlockSync),
|
Override(RunBlockSyncKey, modules.RunBlockSync),
|
||||||
|
Override(RunChainGraphsync, modules.ChainGraphsync),
|
||||||
Override(RunPeerMgrKey, modules.RunPeerMgr),
|
Override(RunPeerMgrKey, modules.RunPeerMgr),
|
||||||
Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
|
Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
|
||||||
|
|
||||||
|
@ -9,6 +9,10 @@ import (
|
|||||||
"github.com/ipfs/go-blockservice"
|
"github.com/ipfs/go-blockservice"
|
||||||
"github.com/ipfs/go-car"
|
"github.com/ipfs/go-car"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
|
graphsync "github.com/ipfs/go-graphsync/impl"
|
||||||
|
"github.com/ipfs/go-graphsync/ipldbridge"
|
||||||
|
gsnet "github.com/ipfs/go-graphsync/network"
|
||||||
|
"github.com/ipfs/go-graphsync/storeutil"
|
||||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p-core/host"
|
||||||
"github.com/libp2p/go-libp2p-core/routing"
|
"github.com/libp2p/go-libp2p-core/routing"
|
||||||
@ -73,6 +77,15 @@ func ChainBlockservice(bs dtypes.ChainBlockstore, rem dtypes.ChainExchange) dtyp
|
|||||||
return blockservice.New(bs, rem)
|
return blockservice.New(bs, rem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ChainGraphsync(mctx helpers.MetricsCtx, lc fx.Lifecycle, ibs dtypes.ChainGCBlockstore, h host.Host) dtypes.ClientGraphsync {
|
||||||
|
graphsyncNetwork := gsnet.NewFromLibp2pHost(h)
|
||||||
|
ipldBridge := ipldbridge.NewIPLDBridge()
|
||||||
|
loader := storeutil.LoaderForBlockstore(ibs)
|
||||||
|
gs := graphsync.New(helpers.LifecycleCtx(mctx, lc), graphsyncNetwork, ipldBridge, loader, nil)
|
||||||
|
|
||||||
|
return gs
|
||||||
|
}
|
||||||
|
|
||||||
func ChainStore(lc fx.Lifecycle, bs dtypes.ChainBlockstore, ds dtypes.MetadataDS, syscalls *types.VMSyscalls) *store.ChainStore {
|
func ChainStore(lc fx.Lifecycle, bs dtypes.ChainBlockstore, ds dtypes.MetadataDS, syscalls *types.VMSyscalls) *store.ChainStore {
|
||||||
chain := store.NewChainStore(bs, ds, syscalls)
|
chain := store.NewChainStore(bs, ds, syscalls)
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ type ChainGCLocker blockstore.GCLocker
|
|||||||
type ChainGCBlockstore blockstore.GCBlockstore
|
type ChainGCBlockstore blockstore.GCBlockstore
|
||||||
type ChainExchange exchange.Interface
|
type ChainExchange exchange.Interface
|
||||||
type ChainBlockService bserv.BlockService
|
type ChainBlockService bserv.BlockService
|
||||||
|
type ChainGraphsync graphsync.GraphExchange
|
||||||
|
|
||||||
type ClientFilestore *filestore.Filestore
|
type ClientFilestore *filestore.Filestore
|
||||||
type ClientBlockstore blockstore.Blockstore
|
type ClientBlockstore blockstore.Blockstore
|
||||||
|
Loading…
Reference in New Issue
Block a user