mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-26 11:11:41 +00:00
Merge branch 'statecache' into rpc
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
bc "github.com/tendermint/tendermint/blockchain"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/consensus"
|
||||
@ -13,15 +14,15 @@ import (
|
||||
"github.com/tendermint/tendermint/rpc"
|
||||
"github.com/tendermint/tendermint/rpc/core"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
type Node struct {
|
||||
lz []p2p.Listener
|
||||
sw *p2p.Switch
|
||||
book *p2p.AddrBook
|
||||
blockStore *bc.BlockStore
|
||||
pexReactor *p2p.PEXReactor
|
||||
blockStore *types.BlockStore
|
||||
bcReactor *bc.BlockchainReactor
|
||||
mempoolReactor *mempl.MempoolReactor
|
||||
consensusState *consensus.ConsensusState
|
||||
consensusReactor *consensus.ConsensusReactor
|
||||
@ -31,7 +32,7 @@ type Node struct {
|
||||
func NewNode() *Node {
|
||||
// Get BlockStore
|
||||
blockStoreDB := dbm.GetDB("blockstore")
|
||||
blockStore := types.NewBlockStore(blockStoreDB)
|
||||
blockStore := bc.NewBlockStore(blockStoreDB)
|
||||
|
||||
// Get State
|
||||
stateDB := dbm.GetDB("state")
|
||||
@ -54,6 +55,9 @@ func NewNode() *Node {
|
||||
book := p2p.NewAddrBook(config.App().GetString("AddrBookFile"))
|
||||
pexReactor := p2p.NewPEXReactor(book)
|
||||
|
||||
// Get BlockchainReactor
|
||||
bcReactor := bc.NewBlockchainReactor(state, blockStore, config.App().GetBool("FastSync"))
|
||||
|
||||
// Get MempoolReactor
|
||||
mempool := mempl.NewMempool(state.Copy())
|
||||
mempoolReactor := mempl.NewMempoolReactor(mempool)
|
||||
@ -65,14 +69,23 @@ func NewNode() *Node {
|
||||
consensusReactor.SetPrivValidator(privValidator)
|
||||
}
|
||||
|
||||
sw := p2p.NewSwitch([]p2p.Reactor{pexReactor, mempoolReactor, consensusReactor})
|
||||
sw.SetChainId(state.Hash(), config.App().GetString("Network"))
|
||||
sw := p2p.NewSwitch()
|
||||
sw.SetNetwork(config.App().GetString("Network"))
|
||||
sw.AddReactor("PEX", pexReactor).Start(sw)
|
||||
sw.AddReactor("MEMPOOL", mempoolReactor).Start(sw)
|
||||
sw.AddReactor("BLOCKCHAIN", bcReactor).Start(sw)
|
||||
if !config.App().GetBool("FastSync") {
|
||||
sw.AddReactor("CONSENSUS", consensusReactor).Start(sw)
|
||||
} else {
|
||||
sw.AddReactor("CONSENSUS", consensusReactor)
|
||||
}
|
||||
|
||||
return &Node{
|
||||
sw: sw,
|
||||
book: book,
|
||||
pexReactor: pexReactor,
|
||||
blockStore: blockStore,
|
||||
pexReactor: pexReactor,
|
||||
bcReactor: bcReactor,
|
||||
mempoolReactor: mempoolReactor,
|
||||
consensusState: consensusState,
|
||||
consensusReactor: consensusReactor,
|
||||
@ -86,7 +99,7 @@ func (n *Node) Start() {
|
||||
go n.inboundConnectionRoutine(l)
|
||||
}
|
||||
n.book.Start()
|
||||
n.sw.Start()
|
||||
//n.sw.StartReactors()
|
||||
}
|
||||
|
||||
func (n *Node) Stop() {
|
||||
|
Reference in New Issue
Block a user