extract blocksync into its own package
This commit is contained in:
+3
-2
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain"
|
||||
"github.com/filecoin-project/lotus/chain/blocksync"
|
||||
"github.com/filecoin-project/lotus/chain/deals"
|
||||
"github.com/filecoin-project/lotus/chain/market"
|
||||
"github.com/filecoin-project/lotus/chain/metrics"
|
||||
@@ -197,14 +198,14 @@ func Online() Option {
|
||||
|
||||
// Filecoin services
|
||||
Override(new(*chain.Syncer), chain.NewSyncer),
|
||||
Override(new(*chain.BlockSync), chain.NewBlockSyncClient),
|
||||
Override(new(*blocksync.BlockSync), blocksync.NewBlockSyncClient),
|
||||
Override(new(*chain.MessagePool), chain.NewMessagePool),
|
||||
|
||||
Override(new(modules.Genesis), modules.ErrorGenesis),
|
||||
Override(SetGenesisKey, modules.SetGenesis),
|
||||
|
||||
Override(new(*hello.Service), hello.NewHelloService),
|
||||
Override(new(*chain.BlockSyncService), chain.NewBlockSyncService),
|
||||
Override(new(*blocksync.BlockSyncService), blocksync.NewBlockSyncService),
|
||||
Override(new(*peermgr.PeerMgr), peermgr.NewPeerMgr),
|
||||
|
||||
Override(RunHelloKey, modules.RunHello),
|
||||
|
||||
+3
-1
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
inet "github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
protocol "github.com/libp2p/go-libp2p-protocol"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
@@ -34,8 +35,9 @@ type Message struct {
|
||||
GenesisHash cid.Cid
|
||||
}
|
||||
|
||||
type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)
|
||||
type Service struct {
|
||||
newStream chain.NewStreamFunc
|
||||
newStream NewStreamFunc
|
||||
|
||||
cs *store.ChainStore
|
||||
syncer *chain.Syncer
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain"
|
||||
"github.com/filecoin-project/lotus/chain/blocksync"
|
||||
"github.com/filecoin-project/lotus/chain/deals"
|
||||
"github.com/filecoin-project/lotus/chain/sub"
|
||||
"github.com/filecoin-project/lotus/node/hello"
|
||||
@@ -37,8 +38,8 @@ func RunPeerMgr(mctx helpers.MetricsCtx, lc fx.Lifecycle, pmgr *peermgr.PeerMgr)
|
||||
go pmgr.Run(helpers.LifecycleCtx(mctx, lc))
|
||||
}
|
||||
|
||||
func RunBlockSync(h host.Host, svc *chain.BlockSyncService) {
|
||||
h.SetStreamHandler(chain.BlockSyncProtocolID, svc.HandleStream)
|
||||
func RunBlockSync(h host.Host, svc *blocksync.BlockSyncService) {
|
||||
h.SetStreamHandler(blocksync.BlockSyncProtocolID, svc.HandleStream)
|
||||
}
|
||||
|
||||
func HandleIncomingBlocks(mctx helpers.MetricsCtx, lc fx.Lifecycle, pubsub *pubsub.PubSub, s *chain.Syncer) {
|
||||
|
||||
Reference in New Issue
Block a user