diff options
author | obscuren <geffobscura@gmail.com> | 2014-03-05 17:42:51 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-03-05 17:42:51 +0800 |
commit | 92f2abdf769f52ea8e5e6d02bf326744e926f5b4 (patch) | |
tree | 234bcf5278e6804736f7392095733ef133e7fe03 /ethereum.go | |
parent | 5b1613d65b0c3471b80990120022b5a745ecab86 (diff) | |
download | go-tangerine-92f2abdf769f52ea8e5e6d02bf326744e926f5b4.tar go-tangerine-92f2abdf769f52ea8e5e6d02bf326744e926f5b4.tar.gz go-tangerine-92f2abdf769f52ea8e5e6d02bf326744e926f5b4.tar.bz2 go-tangerine-92f2abdf769f52ea8e5e6d02bf326744e926f5b4.tar.lz go-tangerine-92f2abdf769f52ea8e5e6d02bf326744e926f5b4.tar.xz go-tangerine-92f2abdf769f52ea8e5e6d02bf326744e926f5b4.tar.zst go-tangerine-92f2abdf769f52ea8e5e6d02bf326744e926f5b4.zip |
Partially refactored server/txpool/block manager/block chain
The Ethereum structure now complies to a EthManager interface which is
being used by the tx pool, block manager and block chain in order to
gain access to each other. It's become simpeler.
TODO: BlockManager => StateManager
Diffstat (limited to 'ethereum.go')
-rw-r--r-- | ethereum.go | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/ethereum.go b/ethereum.go index b4a8cdb4a..2c8b2cceb 100644 --- a/ethereum.go +++ b/ethereum.go @@ -37,10 +37,12 @@ type Ethereum struct { //db *ethdb.LDBDatabase db ethutil.Database // Block manager for processing new blocks and managing the block chain - BlockManager *ethchain.BlockManager + blockManager *ethchain.BlockManager // The transaction pool. Transaction can be pushed on this pool // for later including in the blocks - TxPool *ethchain.TxPool + txPool *ethchain.TxPool + // The canonical chain + blockChain *ethchain.BlockChain // Peers (NYI) peers *list.List // Nonce @@ -87,19 +89,28 @@ func New(caps Caps, usePnp bool) (*Ethereum, error) { serverCaps: caps, nat: nat, } - ethereum.TxPool = ethchain.NewTxPool() - ethereum.TxPool.Speaker = ethereum - ethereum.BlockManager = ethchain.NewBlockManager(ethereum) - - ethereum.TxPool.BlockManager = ethereum.BlockManager - ethereum.BlockManager.TransactionPool = ethereum.TxPool + ethereum.txPool = ethchain.NewTxPool(ethereum) + ethereum.blockChain = ethchain.NewBlockChain(ethereum) + ethereum.blockManager = ethchain.NewBlockManager(ethereum) // Start the tx pool - ethereum.TxPool.Start() + ethereum.txPool.Start() return ethereum, nil } +func (s *Ethereum) BlockChain() *ethchain.BlockChain { + return s.blockChain +} + +func (s *Ethereum) StateManager() *ethchain.BlockManager { + return s.blockManager +} + +func (s *Ethereum) TxPool() *ethchain.TxPool { + return s.txPool +} + func (s *Ethereum) AddPeer(conn net.Conn) { peer := NewPeer(conn, s, true) @@ -253,7 +264,7 @@ func (s *Ethereum) Start() { if ethutil.Config.Seed { ethutil.Config.Log.Debugln("Seeding") // Testnet seed bootstrapping - resp, err := http.Get("http://www.ethereum.org/servers.poc3.txt") + resp, err := http.Get("https://www.ethereum.org/servers.poc3.txt") if err != nil { log.Println("Fetching seed failed:", err) return @@ -292,8 +303,8 @@ func (s *Ethereum) Stop() { close(s.quit) - s.TxPool.Stop() - s.BlockManager.Stop() + s.txPool.Stop() + s.blockManager.Stop() close(s.shutdownChan) } |