p2p: transport should be captive resposibility of router (#7160)

The main (and minor) win of this PR is that the transport is fully the
responsibility of the router and the node doesn't need to be responsible for its lifecylce.
This commit is contained in:
Sam Kleinman
2021-10-26 18:34:44 +02:00
committed by GitHub
parent b15b2c1b78
commit 4bd8c5ab6f
9 changed files with 67 additions and 41 deletions

View File

@@ -486,23 +486,32 @@ func createPeerManager(
}
func createRouter(
p2pLogger log.Logger,
logger log.Logger,
p2pMetrics *p2p.Metrics,
nodeInfo types.NodeInfo,
privKey crypto.PrivKey,
nodeKey types.NodeKey,
peerManager *p2p.PeerManager,
transport p2p.Transport,
options p2p.RouterOptions,
conf *config.Config,
proxyApp proxy.AppConns,
) (*p2p.Router, error) {
p2pLogger := logger.With("module", "p2p")
transport := createTransport(p2pLogger, conf)
ep, err := p2p.NewEndpoint(nodeKey.ID.AddressString(conf.P2P.ListenAddress))
if err != nil {
return nil, err
}
return p2p.NewRouter(
p2pLogger,
p2pMetrics,
nodeInfo,
privKey,
nodeKey.PrivKey,
peerManager,
[]p2p.Transport{transport},
options,
[]p2p.Endpoint{ep},
getRouterConfig(conf, proxyApp),
)
}