graphsync.go 681 Bytes
Newer Older
1 2 3
package node

import (
tavit ohanian's avatar
tavit ohanian committed
4 5 6 7 8 9
	blockstore "gitlab.dms3.io/dms3/go-dms3-blockstore"
	"gitlab.dms3.io/dms3/go-graphsync"
	gsimpl "gitlab.dms3.io/dms3/go-graphsync/impl"
	"gitlab.dms3.io/dms3/go-graphsync/network"
	"gitlab.dms3.io/dms3/go-graphsync/storeutil"
	p2p "gitlab.dms3.io/p2p/go-p2p-core"
10 11
	"go.uber.org/fx"

tavit ohanian's avatar
tavit ohanian committed
12
	"gitlab.dms3.io/dms3/go-dms3/core/node/helpers"
13 14 15
)

// Graphsync constructs a graphsync
tavit ohanian's avatar
tavit ohanian committed
16
func Graphsync(lc fx.Lifecycle, mctx helpers.MetricsCtx, host p2p.Host, bs blockstore.GCBlockstore) graphsync.GraphExchange {
17 18
	ctx := helpers.LifecycleCtx(mctx, lc)

tavit ohanian's avatar
tavit ohanian committed
19
	network := network.NewFromP2pHost(host)
Peter Rabbitson's avatar
Peter Rabbitson committed
20
	return gsimpl.New(ctx, network,
tavit ohanian's avatar
tavit ohanian committed
21
		storeutil.LinkSystemForBlockstore(bs),
22 23
	)
}