From f2a21657660f1d2120814470ae6a34cdb18ad389 Mon Sep 17 00:00:00 2001 From: Yongfeng LI Date: Wed, 28 Mar 2018 14:13:23 +0800 Subject: [PATCH] remove wallet from BlockchainReactor (#496) --- blockchain/reactor.go | 16 ++++------------ node/node.go | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/blockchain/reactor.go b/blockchain/reactor.go index ab346c4b..bf4665d0 100755 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -8,6 +8,7 @@ import ( log "github.com/sirupsen/logrus" cmn "github.com/tendermint/tmlibs/common" + "github.com/bytom/account" "github.com/bytom/blockchain/txfeed" "github.com/bytom/mining/cpuminer" "github.com/bytom/mining/miningpool" @@ -17,7 +18,6 @@ import ( "github.com/bytom/protocol/bc" protocolTypes "github.com/bytom/protocol/bc/types" "github.com/bytom/types" - "github.com/bytom/wallet" ) const ( @@ -27,7 +27,6 @@ const ( statusUpdateIntervalSeconds = 10 maxBlockchainResponseSize = 22020096 + 2 - crosscoreRPCPrefix = "/rpc/" ) // BlockchainReactor handles long-term catchup syncing. @@ -35,7 +34,6 @@ type BlockchainReactor struct { p2p.BaseReactor chain *protocol.Chain - wallet *wallet.Wallet TxFeedTracker *txfeed.Tracker // TODO: move it out from BlockchainReactor blockKeeper *blockKeeper txPool *protocol.TxPool @@ -59,11 +57,10 @@ func (bcr *BlockchainReactor) Info(ctx context.Context) (map[string]interface{}, } // NewBlockchainReactor returns the reactor of whole blockchain. -func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, sw *p2p.Switch, wallet *wallet.Wallet, txfeeds *txfeed.Tracker, miningEnable bool) *BlockchainReactor { +func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, sw *p2p.Switch, accountMgr *account.Manager, txfeeds *txfeed.Tracker, miningEnable bool) *BlockchainReactor { newBlockCh := make(chan *bc.Hash, maxNewBlockChSize) bcr := &BlockchainReactor{ chain: chain, - wallet: wallet, blockKeeper: newBlockKeeper(chain, sw), txPool: txPool, sw: sw, @@ -72,13 +69,8 @@ func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, sw *p2 newBlockCh: newBlockCh, } - if wallet == nil { - bcr.mining = cpuminer.NewCPUMiner(chain, nil, txPool, newBlockCh) - bcr.miningPool = miningpool.NewMiningPool(chain, nil, txPool, newBlockCh) - } else { - bcr.mining = cpuminer.NewCPUMiner(chain, wallet.AccountMgr, txPool, newBlockCh) - bcr.miningPool = miningpool.NewMiningPool(chain, wallet.AccountMgr, txPool, newBlockCh) - } + bcr.mining = cpuminer.NewCPUMiner(chain, accountMgr, txPool, newBlockCh) + bcr.miningPool = miningpool.NewMiningPool(chain, accountMgr, txPool, newBlockCh) bcr.BaseReactor = *p2p.NewBaseReactor("BlockchainReactor", bcr) return bcr diff --git a/node/node.go b/node/node.go index 0c8dbdc5..94474ae5 100755 --- a/node/node.go +++ b/node/node.go @@ -131,7 +131,7 @@ func NewNode(config *cfg.Config) *Node { go accounts.ExpireReservations(ctx, expireReservationsPeriod) } - bcReactor := bc.NewBlockchainReactor(chain, txPool, sw, wallet, txFeed, config.Mining) + bcReactor := bc.NewBlockchainReactor(chain, txPool, sw, accounts, txFeed, config.Mining) sw.AddReactor("BLOCKCHAIN", bcReactor) -- 2.11.0