WIP: integrate graphsync for chainsync requests
This commit is contained in:
+2
-1
@@ -2,9 +2,10 @@ package hello
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
"github.com/ipfs/go-cid"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
||||
@@ -3,11 +3,13 @@ package modules
|
||||
import (
|
||||
"context"
|
||||
|
||||
eventbus "github.com/libp2p/go-eventbus"
|
||||
event "github.com/libp2p/go-libp2p-core/event"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
inet "github.com/libp2p/go-libp2p-core/network"
|
||||
peer "github.com/libp2p/go-libp2p-peer"
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"go.uber.org/fx"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket/discovery"
|
||||
@@ -23,20 +25,26 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
)
|
||||
|
||||
func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.Service) {
|
||||
func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.Service) error {
|
||||
h.SetStreamHandler(hello.ProtocolID, svc.HandleStream)
|
||||
|
||||
bundle := inet.NotifyBundle{
|
||||
ConnectedF: func(_ inet.Network, c inet.Conn) {
|
||||
sub, err := h.EventBus().Subscribe(new(event.EvtPeerIdentificationCompleted), eventbus.BufSize(1024))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to subscribe to event bus: %w", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for evt := range sub.Out() {
|
||||
pic := evt.(event.EvtPeerIdentificationCompleted)
|
||||
go func() {
|
||||
if err := svc.SayHello(helpers.LifecycleCtx(mctx, lc), c.RemotePeer()); err != nil {
|
||||
if err := svc.SayHello(helpers.LifecycleCtx(mctx, lc), pic.Peer); err != nil {
|
||||
log.Warnw("failed to say hello", "error", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
},
|
||||
}
|
||||
h.Network().Notify(&bundle)
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunPeerMgr(mctx helpers.MetricsCtx, lc fx.Lifecycle, pmgr *peermgr.PeerMgr) {
|
||||
|
||||
Reference in New Issue
Block a user