diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-18 20:22:59 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-18 20:22:59 +0800 |
commit | 0dc566124aee24cf3f01b4e586bde7752da89824 (patch) | |
tree | 22bfe271447f8b42598b3066cb92d87df93c7095 | |
parent | 721e8ae93f9b8918ff4bc74af86c530bacacea00 (diff) | |
download | dexon-0dc566124aee24cf3f01b4e586bde7752da89824.tar dexon-0dc566124aee24cf3f01b4e586bde7752da89824.tar.gz dexon-0dc566124aee24cf3f01b4e586bde7752da89824.tar.bz2 dexon-0dc566124aee24cf3f01b4e586bde7752da89824.tar.lz dexon-0dc566124aee24cf3f01b4e586bde7752da89824.tar.xz dexon-0dc566124aee24cf3f01b4e586bde7752da89824.tar.zst dexon-0dc566124aee24cf3f01b4e586bde7752da89824.zip |
Merge fixes
-rw-r--r-- | core/chain_manager.go | 5 | ||||
-rw-r--r-- | core/transaction_pool.go | 6 | ||||
-rw-r--r-- | core/types/common.go | 5 | ||||
-rw-r--r-- | eth/backend.go | 4 |
4 files changed, 8 insertions, 12 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go index 4bbecd109..e6268c01e 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -101,7 +101,10 @@ func NewChainManager(mux *event.TypeMux) *ChainManager { } func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlock []byte) { - return self.TD, self.CurrentBlock.Hash(), self.Genesis().Hash() + self.mu.RLock() + defer self.mu.RUnlock() + + return self.td, self.currentBlock.Hash(), self.Genesis().Hash() } func (self *ChainManager) SetProcessor(proc types.BlockProcessor) { diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 86286f23d..2bbda7d90 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -72,19 +72,17 @@ type TxPool struct { subscribers []chan TxMsg - broadcaster types.Broadcaster chainManager *ChainManager eventMux *event.TypeMux } -func NewTxPool(chainManager *ChainManager, broadcaster types.Broadcaster, eventMux *event.TypeMux) *TxPool { +func NewTxPool(chainManager *ChainManager, eventMux *event.TypeMux) *TxPool { return &TxPool{ pool: list.New(), queueChan: make(chan *types.Transaction, txPoolQueueSize), quit: make(chan bool), chainManager: chainManager, eventMux: eventMux, - broadcaster: broadcaster, } } @@ -96,7 +94,7 @@ func (pool *TxPool) addTransaction(tx *types.Transaction) { pool.pool.PushBack(tx) // Broadcast the transaction to the rest of the peers - pool.Ethereum.EventMux().Post(TxPreEvent{tx}) + pool.eventMux.Post(TxPreEvent{tx}) } func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { diff --git a/core/types/common.go b/core/types/common.go index 89cb5f498..ba88b77e1 100644 --- a/core/types/common.go +++ b/core/types/common.go @@ -4,13 +4,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/state" - "github.com/ethereum/go-ethereum/wire" ) type BlockProcessor interface { Process(*Block) (*big.Int, state.Messages, error) } - -type Broadcaster interface { - Broadcast(wire.MsgType, []interface{}) -} diff --git a/eth/backend.go b/eth/backend.go index ef82a5bfc..0aad6a514 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -69,9 +69,9 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke eventMux: &event.TypeMux{}, } - eth.txPool = core.NewTxPool(eth) eth.chainManager = core.NewChainManager(eth.EventMux()) - eth.blockManager = core.NewBlockManager(eth) + eth.txPool = core.NewTxPool(eth.chainManager, eth.EventMux()) + eth.blockManager = core.NewBlockManager(eth.txPool, eth.chainManager, eth.EventMux()) eth.chainManager.SetProcessor(eth.blockManager) eth.whisper = whisper.New() |