node+consensus: handshaker initialization (#7283)

This mostly just pushes more of initialization out of the node package.
This commit is contained in:
Sam Kleinman
2021-11-15 13:28:52 -05:00
committed by GitHub
parent f28d629e28
commit a15ae5b53a
6 changed files with 63 additions and 66 deletions

View File

@@ -224,7 +224,10 @@ func makeNode(cfg *config.Config,
// Create the handshaker, which calls RequestInfo, sets the AppVersion on the state,
// and replays any blocks as necessary to sync tendermint with the app.
if !stateSync {
if err := doHandshake(stateStore, state, blockStore, genDoc, eventBus, proxyApp, logger); err != nil {
if err := consensus.NewHandshaker(
logger.With("module", "handshaker"),
stateStore, state, blockStore, eventBus, genDoc,
).Handshake(proxyApp); err != nil {
return nil, combineCloseError(err, makeCloser(closers))
}

View File

@@ -134,26 +134,6 @@ func createAndStartIndexerService(
return indexerService, eventSinks, nil
}
func doHandshake(
stateStore sm.Store,
state sm.State,
blockStore sm.BlockStore,
genDoc *types.GenesisDoc,
eventBus types.BlockEventPublisher,
proxyApp proxy.AppConns,
logger log.Logger,
) error {
handshaker := consensus.NewHandshaker(stateStore, state, blockStore, genDoc)
handshaker.SetLogger(logger.With("module", "handshaker"))
handshaker.SetEventBus(eventBus)
if err := handshaker.Handshake(proxyApp); err != nil {
return fmt.Errorf("error during handshake: %v", err)
}
return nil
}
func logNodeStartupInfo(state sm.State, pubKey crypto.PubKey, logger log.Logger, mode string) {
// Log the version info.
logger.Info("Version info",