Pubsub for blocks/messages

This commit is contained in:
Łukasz Magiera
2019-07-08 16:07:09 +02:00
parent e162b5395c
commit d1eb9073d1
6 changed files with 139 additions and 56 deletions
-20
View File
@@ -5,9 +5,6 @@ import (
"fmt"
"github.com/filecoin-project/go-lotus/chain"
"github.com/filecoin-project/go-lotus/lib/cborrpc"
"github.com/filecoin-project/go-lotus/node/modules/helpers"
"go.uber.org/fx"
"github.com/libp2p/go-libp2p-core/host"
"github.com/ipfs/go-cid"
@@ -102,20 +99,3 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
return nil
}
func Run(mctx helpers.MetricsCtx, lc fx.Lifecycle, hs *Service, h host.Host) {
ctx := helpers.LifecycleCtx(mctx, lc)
h.SetStreamHandler(ProtocolID, hs.HandleStream)
bundle := inet.NotifyBundle{
ConnectedF: func(_ inet.Network, c inet.Conn) {
go func() {
if err := hs.SayHello(ctx, c.RemotePeer()); err != nil {
log.Error("failed to say hello: ", err)
return
}
}()
},
}
h.Network().Notify(&bundle)
}