p2p: remove final shims from p2p package (#7136)

This is, perhaps, the trival final piece of #7075 that I've been
working on.

There's more work to be done: 
- push more of the setup into the pacakges themselves
- move channel-based sending/filtering out of the 
- simplify the buffering throuhgout the p2p stack.
This commit is contained in:
Sam Kleinman
2021-10-15 16:08:09 -04:00
committed by GitHub
parent 7143f14a63
commit ca8f004112
11 changed files with 158 additions and 180 deletions

View File

@@ -303,11 +303,14 @@ func makeNode(cfg *config.Config,
sm.BlockExecutorWithMetrics(nodeMetrics.state),
)
csReactor, csState := createConsensusReactor(
csReactor, csState, err := createConsensusReactor(
cfg, state, blockExec, blockStore, mp, evPool,
privValidator, nodeMetrics.consensus, stateSync || blockSync, eventBus,
peerManager, router, consensusLogger,
)
if err != nil {
return nil, combineCloseError(err, makeCloser(closers))
}
// Create the blockchain reactor. Note, we do not start block sync if we're
// doing a state sync first.
@@ -334,7 +337,17 @@ func makeNode(cfg *config.Config,
// we should clean this whole thing up. See:
// https://github.com/tendermint/tendermint/issues/4644
ssLogger := logger.With("module", "statesync")
channels := makeChannelsFromShims(router, statesync.ChannelShims)
ssChDesc := statesync.GetChannelDescriptors()
channels := make(map[p2p.ChannelID]*p2p.Channel, len(ssChDesc))
for idx := range ssChDesc {
chd := ssChDesc[idx]
ch, err := router.OpenChannel(chd)
if err != nil {
return nil, err
}
channels[ch.ID] = ch
}
peerUpdates := peerManager.Subscribe()
stateSyncReactor := statesync.NewReactor(
@@ -1088,23 +1101,3 @@ func getRouterConfig(conf *config.Config, proxyApp proxy.AppConns) p2p.RouterOpt
return opts
}
// FIXME: Temporary helper function, shims should be removed.
func makeChannelsFromShims(
router *p2p.Router,
chDescs []*p2p.ChannelDescriptor,
) map[p2p.ChannelID]*p2p.Channel {
channels := map[p2p.ChannelID]*p2p.Channel{}
for idx := range chDescs {
chDesc := chDescs[idx]
ch, err := router.OpenChannel(chDesc)
if err != nil {
panic(fmt.Sprintf("failed to open channel %v: %v", chDesc.ID, err))
}
channels[chDesc.ID] = ch
}
return channels
}