|
|
@ -217,11 +217,51 @@ func NewNode(config *cfg.Config, |
|
|
|
return nil, fmt.Errorf("Error starting proxy app connections: %v", err) |
|
|
|
} |
|
|
|
|
|
|
|
// EventBus and IndexerService must be started before the handshake because
|
|
|
|
// we might need to index the txs of the replayed block as this might not have happened
|
|
|
|
// when the node stopped last time (i.e. the node stopped after it saved the block
|
|
|
|
// but before it indexed the txs, or, endblocker panicked)
|
|
|
|
eventBus := types.NewEventBus() |
|
|
|
eventBus.SetLogger(logger.With("module", "events")) |
|
|
|
|
|
|
|
err = eventBus.Start() |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
// Transaction indexing
|
|
|
|
var txIndexer txindex.TxIndexer |
|
|
|
switch config.TxIndex.Indexer { |
|
|
|
case "kv": |
|
|
|
store, err := dbProvider(&DBContext{"tx_index", config}) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
if config.TxIndex.IndexTags != "" { |
|
|
|
txIndexer = kv.NewTxIndex(store, kv.IndexTags(splitAndTrimEmpty(config.TxIndex.IndexTags, ",", " "))) |
|
|
|
} else if config.TxIndex.IndexAllTags { |
|
|
|
txIndexer = kv.NewTxIndex(store, kv.IndexAllTags()) |
|
|
|
} else { |
|
|
|
txIndexer = kv.NewTxIndex(store) |
|
|
|
} |
|
|
|
default: |
|
|
|
txIndexer = &null.TxIndex{} |
|
|
|
} |
|
|
|
|
|
|
|
indexerService := txindex.NewIndexerService(txIndexer, eventBus) |
|
|
|
indexerService.SetLogger(logger.With("module", "txindex")) |
|
|
|
|
|
|
|
err = indexerService.Start() |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
// Create the handshaker, which calls RequestInfo, sets the AppVersion on the state,
|
|
|
|
// and replays any blocks as necessary to sync tendermint with the app.
|
|
|
|
consensusLogger := logger.With("module", "consensus") |
|
|
|
handshaker := cs.NewHandshaker(stateDB, state, blockStore, genDoc) |
|
|
|
handshaker.SetLogger(consensusLogger) |
|
|
|
handshaker.SetEventBus(eventBus) |
|
|
|
if err := handshaker.Handshake(proxyApp); err != nil { |
|
|
|
return nil, fmt.Errorf("Error during handshake: %v", err) |
|
|
|
} |
|
|
@ -343,35 +383,10 @@ func NewNode(config *cfg.Config, |
|
|
|
consensusReactor := cs.NewConsensusReactor(consensusState, fastSync, cs.ReactorMetrics(csMetrics)) |
|
|
|
consensusReactor.SetLogger(consensusLogger) |
|
|
|
|
|
|
|
eventBus := types.NewEventBus() |
|
|
|
eventBus.SetLogger(logger.With("module", "events")) |
|
|
|
|
|
|
|
// services which will be publishing and/or subscribing for messages (events)
|
|
|
|
// consensusReactor will set it on consensusState and blockExecutor
|
|
|
|
consensusReactor.SetEventBus(eventBus) |
|
|
|
|
|
|
|
// Transaction indexing
|
|
|
|
var txIndexer txindex.TxIndexer |
|
|
|
switch config.TxIndex.Indexer { |
|
|
|
case "kv": |
|
|
|
store, err := dbProvider(&DBContext{"tx_index", config}) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
if config.TxIndex.IndexTags != "" { |
|
|
|
txIndexer = kv.NewTxIndex(store, kv.IndexTags(splitAndTrimEmpty(config.TxIndex.IndexTags, ",", " "))) |
|
|
|
} else if config.TxIndex.IndexAllTags { |
|
|
|
txIndexer = kv.NewTxIndex(store, kv.IndexAllTags()) |
|
|
|
} else { |
|
|
|
txIndexer = kv.NewTxIndex(store) |
|
|
|
} |
|
|
|
default: |
|
|
|
txIndexer = &null.TxIndex{} |
|
|
|
} |
|
|
|
|
|
|
|
indexerService := txindex.NewIndexerService(txIndexer, eventBus) |
|
|
|
indexerService.SetLogger(logger.With("module", "txindex")) |
|
|
|
|
|
|
|
p2pLogger := logger.With("module", "p2p") |
|
|
|
nodeInfo, err := makeNodeInfo( |
|
|
|
config, |
|
|
@ -534,11 +549,6 @@ func (n *Node) OnStart() error { |
|
|
|
time.Sleep(genTime.Sub(now)) |
|
|
|
} |
|
|
|
|
|
|
|
err := n.eventBus.Start() |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
// Add private IDs to addrbook to block those peers being added
|
|
|
|
n.addrBook.AddPrivateIDs(splitAndTrimEmpty(n.config.P2P.PrivatePeerIDs, ",", " ")) |
|
|
|
|
|
|
@ -582,8 +592,7 @@ func (n *Node) OnStart() error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// start tx indexer
|
|
|
|
return n.indexerService.Start() |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
// OnStop stops the Node. It implements cmn.Service.
|
|
|
|