diff --git a/block_pool.go b/block_pool.go index 334db9c1b5..49fa07eb15 100644 --- a/block_pool.go +++ b/block_pool.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethwire" @@ -20,7 +20,7 @@ var poollogger = ethlog.NewLogger("BPOOL") type block struct { from *Peer peer *Peer - block *ethchain.Block + block *chain.Block reqAt time.Time requested int } @@ -73,7 +73,7 @@ func (self *BlockPool) HasCommonHash(hash []byte) bool { return self.eth.ChainManager().GetBlock(hash) != nil } -func (self *BlockPool) Blocks() (blocks ethchain.Blocks) { +func (self *BlockPool) Blocks() (blocks chain.Blocks) { for _, item := range self.pool { if item.block != nil { blocks = append(blocks, item.block) @@ -123,15 +123,15 @@ func (self *BlockPool) AddHash(hash []byte, peer *Peer) { } } -func (self *BlockPool) Add(b *ethchain.Block, peer *Peer) { +func (self *BlockPool) Add(b *chain.Block, peer *Peer) { self.addBlock(b, peer, false) } -func (self *BlockPool) AddNew(b *ethchain.Block, peer *Peer) { +func (self *BlockPool) AddNew(b *chain.Block, peer *Peer) { self.addBlock(b, peer, true) } -func (self *BlockPool) addBlock(b *ethchain.Block, peer *Peer, newBlock bool) { +func (self *BlockPool) addBlock(b *chain.Block, peer *Peer, newBlock bool) { self.mut.Lock() defer self.mut.Unlock() @@ -262,7 +262,7 @@ out: /* if !self.fetchingHashes { blocks := self.Blocks() - ethchain.BlockBy(ethchain.Number).Sort(blocks) + chain.BlockBy(chain.Number).Sort(blocks) if len(blocks) > 0 { if !self.eth.ChainManager().HasBlock(b.PrevHash) && self.pool[string(b.PrevHash)] == nil && !self.fetchingHashes { @@ -283,7 +283,7 @@ out: break out case <-procTimer.C: blocks := self.Blocks() - ethchain.BlockBy(ethchain.Number).Sort(blocks) + chain.BlockBy(chain.Number).Sort(blocks) // Find common block for i, block := range blocks { diff --git a/ethchain/.gitignore b/chain/.gitignore similarity index 100% rename from ethchain/.gitignore rename to chain/.gitignore diff --git a/ethchain/asm.go b/chain/asm.go similarity index 98% rename from ethchain/asm.go rename to chain/asm.go index 57bb2fcf9b..875321c1ce 100644 --- a/ethchain/asm.go +++ b/chain/asm.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "fmt" diff --git a/ethchain/block.go b/chain/block.go similarity index 99% rename from ethchain/block.go rename to chain/block.go index a10da97ec9..17a19d391d 100644 --- a/ethchain/block.go +++ b/chain/block.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "bytes" diff --git a/ethchain/bloom.go b/chain/bloom.go similarity index 97% rename from ethchain/bloom.go rename to chain/bloom.go index 5317ca0b1c..9d2cf439d2 100644 --- a/ethchain/bloom.go +++ b/chain/bloom.go @@ -1,4 +1,4 @@ -package ethchain +package chain type BloomFilter struct { bin []byte diff --git a/ethchain/bloom9.go b/chain/bloom9.go similarity index 98% rename from ethchain/bloom9.go rename to chain/bloom9.go index 8fa7b6339a..60cafdb4ba 100644 --- a/ethchain/bloom9.go +++ b/chain/bloom9.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "math/big" diff --git a/ethchain/bloom9_test.go b/chain/bloom9_test.go similarity index 94% rename from ethchain/bloom9_test.go rename to chain/bloom9_test.go index 40f30f35d8..b5a269504e 100644 --- a/ethchain/bloom9_test.go +++ b/chain/bloom9_test.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "testing" diff --git a/ethchain/bloom_test.go b/chain/bloom_test.go similarity index 95% rename from ethchain/bloom_test.go rename to chain/bloom_test.go index ea53d539c4..13c0d94e49 100644 --- a/ethchain/bloom_test.go +++ b/chain/bloom_test.go @@ -1,4 +1,4 @@ -package ethchain +package chain import "testing" diff --git a/ethchain/chain_manager.go b/chain/chain_manager.go similarity index 99% rename from ethchain/chain_manager.go rename to chain/chain_manager.go index 46990bb224..83ae21dcc1 100644 --- a/ethchain/chain_manager.go +++ b/chain/chain_manager.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "bytes" diff --git a/chain/chain_manager_test.go b/chain/chain_manager_test.go new file mode 100644 index 0000000000..fef1d2010b --- /dev/null +++ b/chain/chain_manager_test.go @@ -0,0 +1 @@ +package chain diff --git a/ethchain/dagger.go b/chain/dagger.go similarity index 99% rename from ethchain/dagger.go rename to chain/dagger.go index 7efcf469de..bb6b136f6d 100644 --- a/ethchain/dagger.go +++ b/chain/dagger.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "hash" diff --git a/ethchain/dagger_test.go b/chain/dagger_test.go similarity index 95% rename from ethchain/dagger_test.go rename to chain/dagger_test.go index 2ffba0485d..b40cd9742e 100644 --- a/ethchain/dagger_test.go +++ b/chain/dagger_test.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "math/big" diff --git a/ethchain/derive_sha.go b/chain/derive_sha.go similarity index 95% rename from ethchain/derive_sha.go rename to chain/derive_sha.go index b41252e39a..92db90d957 100644 --- a/ethchain/derive_sha.go +++ b/chain/derive_sha.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "github.com/ethereum/go-ethereum/ethtrie" diff --git a/ethchain/error.go b/chain/error.go similarity index 99% rename from ethchain/error.go rename to chain/error.go index 82949141ab..204b8b8738 100644 --- a/ethchain/error.go +++ b/chain/error.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "fmt" diff --git a/ethchain/events.go b/chain/events.go similarity index 95% rename from ethchain/events.go rename to chain/events.go index 304e741b79..2703e955d0 100644 --- a/ethchain/events.go +++ b/chain/events.go @@ -1,4 +1,4 @@ -package ethchain +package chain // TxPreEvent is posted when a transaction enters the transaction pool. type TxPreEvent struct{ Tx *Transaction } diff --git a/ethchain/fees.go b/chain/fees.go similarity index 80% rename from ethchain/fees.go rename to chain/fees.go index 901357439b..4df6d365d8 100644 --- a/ethchain/fees.go +++ b/chain/fees.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "math/big" diff --git a/ethchain/filter.go b/chain/filter.go similarity index 99% rename from ethchain/filter.go rename to chain/filter.go index a88d36467b..2aecb4f585 100644 --- a/ethchain/filter.go +++ b/chain/filter.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "bytes" diff --git a/ethchain/filter_test.go b/chain/filter_test.go similarity index 82% rename from ethchain/filter_test.go rename to chain/filter_test.go index e569b37748..abfbf4b873 100644 --- a/ethchain/filter_test.go +++ b/chain/filter_test.go @@ -1,4 +1,4 @@ -package ethchain +package chain import "testing" diff --git a/ethchain/genesis.go b/chain/genesis.go similarity index 98% rename from ethchain/genesis.go rename to chain/genesis.go index d94e658b64..2f3b1919bb 100644 --- a/ethchain/genesis.go +++ b/chain/genesis.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "math/big" diff --git a/ethchain/helper_test.go b/chain/helper_test.go similarity index 99% rename from ethchain/helper_test.go rename to chain/helper_test.go index a863c75416..59d1c4ccad 100644 --- a/ethchain/helper_test.go +++ b/chain/helper_test.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "container/list" diff --git a/ethchain/state_manager.go b/chain/state_manager.go similarity index 99% rename from ethchain/state_manager.go rename to chain/state_manager.go index d48d96a516..f78eb925a2 100644 --- a/ethchain/state_manager.go +++ b/chain/state_manager.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "bytes" diff --git a/ethchain/state_transition.go b/chain/state_transition.go similarity index 99% rename from ethchain/state_transition.go rename to chain/state_transition.go index ad7b320c42..4c62633c5f 100644 --- a/ethchain/state_transition.go +++ b/chain/state_transition.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "fmt" diff --git a/ethchain/transaction.go b/chain/transaction.go similarity index 99% rename from ethchain/transaction.go rename to chain/transaction.go index 331f44b555..ef95432afa 100644 --- a/ethchain/transaction.go +++ b/chain/transaction.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "bytes" diff --git a/ethchain/transaction_pool.go b/chain/transaction_pool.go similarity index 99% rename from ethchain/transaction_pool.go rename to chain/transaction_pool.go index 7bd3e9ffd2..861ebdf003 100644 --- a/ethchain/transaction_pool.go +++ b/chain/transaction_pool.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "bytes" diff --git a/chain/transaction_test.go b/chain/transaction_test.go new file mode 100644 index 0000000000..fef1d2010b --- /dev/null +++ b/chain/transaction_test.go @@ -0,0 +1 @@ +package chain diff --git a/ethchain/types.go b/chain/types.go similarity index 99% rename from ethchain/types.go rename to chain/types.go index d0e7fcfb04..9871ae07b8 100644 --- a/ethchain/types.go +++ b/chain/types.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "fmt" diff --git a/ethchain/vm_env.go b/chain/vm_env.go similarity index 98% rename from ethchain/vm_env.go rename to chain/vm_env.go index 1bb67dbd00..d42351713d 100644 --- a/ethchain/vm_env.go +++ b/chain/vm_env.go @@ -1,4 +1,4 @@ -package ethchain +package chain import ( "math/big" diff --git a/cmd/mist/bindings.go b/cmd/mist/bindings.go index 0a6427938c..03d35a574b 100644 --- a/cmd/mist/bindings.go +++ b/cmd/mist/bindings.go @@ -22,7 +22,7 @@ import ( "os" "strconv" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethutil" @@ -110,7 +110,7 @@ func (self *Gui) DumpState(hash, path string) { if len(hash) == 0 { stateDump = self.eth.StateManager().CurrentState().Dump() } else { - var block *ethchain.Block + var block *chain.Block if hash[0] == '#' { i, _ := strconv.Atoi(hash[1:]) block = self.eth.ChainManager().GetBlockByNumber(uint64(i)) diff --git a/cmd/mist/debugger.go b/cmd/mist/debugger.go index ff3a30b3b4..d786a03953 100644 --- a/cmd/mist/debugger.go +++ b/cmd/mist/debugger.go @@ -24,7 +24,7 @@ import ( "strings" "unicode" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/utils" @@ -81,7 +81,7 @@ func (self *DebuggerWindow) SetData(data string) { func (self *DebuggerWindow) SetAsm(data []byte) { self.win.Root().Call("clearAsm") - dis := ethchain.Disassemble(data) + dis := chain.Disassemble(data) for _, str := range dis { self.win.Root().Call("setAsm", str) } diff --git a/cmd/mist/ext_app.go b/cmd/mist/ext_app.go index 7680106f04..cb014aec41 100644 --- a/cmd/mist/ext_app.go +++ b/cmd/mist/ext_app.go @@ -20,7 +20,7 @@ package main import ( "encoding/json" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/event" @@ -36,7 +36,7 @@ type AppContainer interface { Window() *qml.Window Engine() *qml.Engine - NewBlock(*ethchain.Block) + NewBlock(*chain.Block) NewWatcher(chan bool) Messages(ethstate.Messages, string) Post(string, int) @@ -44,12 +44,12 @@ type AppContainer interface { type ExtApplication struct { *ethpipe.JSPipe - eth ethchain.EthManager + eth chain.EthManager events event.Subscription watcherQuitChan chan bool - filters map[string]*ethchain.Filter + filters map[string]*chain.Filter container AppContainer lib *UiLib @@ -60,7 +60,7 @@ func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication { JSPipe: ethpipe.NewJSPipe(lib.eth), eth: lib.eth, watcherQuitChan: make(chan bool), - filters: make(map[string]*ethchain.Filter), + filters: make(map[string]*chain.Filter), container: container, lib: lib, } @@ -80,7 +80,7 @@ func (app *ExtApplication) run() { // Subscribe to events mux := app.lib.eth.EventMux() - app.events = mux.Subscribe(ethchain.NewBlockEvent{}, ethstate.Messages(nil)) + app.events = mux.Subscribe(chain.NewBlockEvent{}, ethstate.Messages(nil)) // Call the main loop go app.mainLoop() @@ -106,7 +106,7 @@ func (app *ExtApplication) stop() { func (app *ExtApplication) mainLoop() { for ev := range app.events.Chan() { switch ev := ev.(type) { - case ethchain.NewBlockEvent: + case chain.NewBlockEvent: app.container.NewBlock(ev.Block) case ethstate.Messages: diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index e6da334752..c917ad06e9 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -31,7 +31,7 @@ import ( "time" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethminer" @@ -286,7 +286,7 @@ func (gui *Gui) loadAddressBook() { } } -func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) { +func (gui *Gui) insertTransaction(window string, tx *chain.Transaction) { pipe := ethpipe.New(gui.eth) nameReg := pipe.World().Config().Get("NameReg") addr := gui.address() @@ -336,7 +336,7 @@ func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) { func (gui *Gui) readPreviousTransactions() { it := gui.txDb.Db().NewIterator(nil, nil) for it.Next() { - tx := ethchain.NewTransactionFromBytes(it.Value()) + tx := chain.NewTransactionFromBytes(it.Value()) gui.insertTransaction("post", tx) @@ -344,7 +344,7 @@ func (gui *Gui) readPreviousTransactions() { it.Release() } -func (gui *Gui) processBlock(block *ethchain.Block, initial bool) { +func (gui *Gui) processBlock(block *chain.Block, initial bool) { name := strings.Trim(gui.pipe.World().Config().Get("NameReg").Storage(block.Coinbase).Str(), "\x00") b := ethpipe.NewJSBlock(block) b.Name = name @@ -407,9 +407,9 @@ func (gui *Gui) update() { events := gui.eth.EventMux().Subscribe( eth.ChainSyncEvent{}, eth.PeerListEvent{}, - ethchain.NewBlockEvent{}, - ethchain.TxPreEvent{}, - ethchain.TxPostEvent{}, + chain.NewBlockEvent{}, + chain.TxPreEvent{}, + chain.TxPostEvent{}, ethminer.Event{}, ) @@ -425,13 +425,13 @@ func (gui *Gui) update() { return } switch ev := ev.(type) { - case ethchain.NewBlockEvent: + case chain.NewBlockEvent: gui.processBlock(ev.Block, false) if bytes.Compare(ev.Block.Coinbase, gui.address()) == 0 { gui.setWalletValue(gui.eth.StateManager().CurrentState().GetAccount(gui.address()).Balance(), nil) } - case ethchain.TxPreEvent: + case chain.TxPreEvent: tx := ev.Tx object := state.GetAccount(gui.address()) @@ -444,7 +444,7 @@ func (gui *Gui) update() { gui.setWalletValue(object.Balance(), unconfirmedFunds) gui.insertTransaction("pre", tx) - case ethchain.TxPostEvent: + case chain.TxPostEvent: tx := ev.Tx object := state.GetAccount(gui.address()) diff --git a/cmd/mist/html_container.go b/cmd/mist/html_container.go index 2e28180274..96bae1a9af 100644 --- a/cmd/mist/html_container.go +++ b/cmd/mist/html_container.go @@ -27,7 +27,7 @@ import ( "path" "path/filepath" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" @@ -138,7 +138,7 @@ func (app *HtmlApplication) Window() *qml.Window { return app.win } -func (app *HtmlApplication) NewBlock(block *ethchain.Block) { +func (app *HtmlApplication) NewBlock(block *chain.Block) { b := ðpipe.JSBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())} app.webView.Call("onNewBlockCb", b) } diff --git a/cmd/mist/qml_container.go b/cmd/mist/qml_container.go index 7538fb919c..3318786e79 100644 --- a/cmd/mist/qml_container.go +++ b/cmd/mist/qml_container.go @@ -21,7 +21,7 @@ import ( "fmt" "runtime" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" @@ -65,7 +65,7 @@ func (app *QmlApplication) NewWatcher(quitChan chan bool) { } // Events -func (app *QmlApplication) NewBlock(block *ethchain.Block) { +func (app *QmlApplication) NewBlock(block *chain.Block) { pblock := ðpipe.JSBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())} app.win.Call("onNewBlockCb", pblock) } diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go index 32ca3c2c91..a9b560b6fc 100644 --- a/cmd/mist/ui_lib.go +++ b/cmd/mist/ui_lib.go @@ -25,7 +25,7 @@ import ( "strings" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethcrypto" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" @@ -120,7 +120,7 @@ func (self *UiLib) PastPeers() *ethutil.List { } func (self *UiLib) ImportTx(rlpTx string) { - tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx)) + tx := chain.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx)) self.eth.TxPool().QueueTransaction(tx) } @@ -221,8 +221,8 @@ func (self *UiLib) NewFilter(object map[string]interface{}) (id int) { } func (self *UiLib) NewFilterString(typ string) (id int) { - filter := ethchain.NewFilter(self.eth) - filter.BlockCallback = func(block *ethchain.Block) { + filter := chain.NewFilter(self.eth) + filter.BlockCallback = func(block *chain.Block) { self.win.Root().Call("invokeFilterCallback", "{}", id) } id = self.eth.InstallFilter(filter) diff --git a/ethchain/chain_manager_test.go b/ethchain/chain_manager_test.go deleted file mode 100644 index 3603fd8a78..0000000000 --- a/ethchain/chain_manager_test.go +++ /dev/null @@ -1 +0,0 @@ -package ethchain diff --git a/ethchain/transaction_test.go b/ethchain/transaction_test.go deleted file mode 100644 index 3603fd8a78..0000000000 --- a/ethchain/transaction_test.go +++ /dev/null @@ -1 +0,0 @@ -package ethchain diff --git a/ethereum.go b/ethereum.go index a389c663d5..489e88b8a3 100644 --- a/ethereum.go +++ b/ethereum.go @@ -14,7 +14,7 @@ import ( "sync/atomic" "time" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethcrypto" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethstate" @@ -50,12 +50,12 @@ type Ethereum struct { // DB interface db ethutil.Database // State manager for processing new blocks and managing the over all states - stateManager *ethchain.StateManager + stateManager *chain.StateManager // The transaction pool. Transaction can be pushed on this pool // for later including in the blocks - txPool *ethchain.TxPool + txPool *chain.TxPool // The canonical chain - blockChain *ethchain.ChainManager + blockChain *chain.ChainManager // The block pool blockPool *BlockPool // Eventer @@ -94,7 +94,7 @@ type Ethereum struct { filterMu sync.RWMutex filterId int - filters map[int]*ethchain.Filter + filters map[int]*chain.Filter } func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager *ethcrypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) { @@ -124,13 +124,13 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager keyManager: keyManager, clientIdentity: clientIdentity, isUpToDate: true, - filters: make(map[int]*ethchain.Filter), + filters: make(map[int]*chain.Filter), } ethereum.blockPool = NewBlockPool(ethereum) - ethereum.txPool = ethchain.NewTxPool(ethereum) - ethereum.blockChain = ethchain.NewChainManager(ethereum) - ethereum.stateManager = ethchain.NewStateManager(ethereum) + ethereum.txPool = chain.NewTxPool(ethereum) + ethereum.blockChain = chain.NewChainManager(ethereum) + ethereum.stateManager = chain.NewStateManager(ethereum) // Start the tx pool ethereum.txPool.Start() @@ -146,15 +146,15 @@ func (s *Ethereum) ClientIdentity() ethwire.ClientIdentity { return s.clientIdentity } -func (s *Ethereum) ChainManager() *ethchain.ChainManager { +func (s *Ethereum) ChainManager() *chain.ChainManager { return s.blockChain } -func (s *Ethereum) StateManager() *ethchain.StateManager { +func (s *Ethereum) StateManager() *chain.StateManager { return s.stateManager } -func (s *Ethereum) TxPool() *ethchain.TxPool { +func (s *Ethereum) TxPool() *chain.TxPool { return s.txPool } func (s *Ethereum) BlockPool() *BlockPool { @@ -590,7 +590,7 @@ out: // InstallFilter adds filter for blockchain events. // The filter's callbacks will run for matching blocks and messages. // The filter should not be modified after it has been installed. -func (self *Ethereum) InstallFilter(filter *ethchain.Filter) (id int) { +func (self *Ethereum) InstallFilter(filter *chain.Filter) (id int) { self.filterMu.Lock() id = self.filterId self.filters[id] = filter @@ -607,7 +607,7 @@ func (self *Ethereum) UninstallFilter(id int) { // GetFilter retrieves a filter installed using InstallFilter. // The filter may not be modified. -func (self *Ethereum) GetFilter(id int) *ethchain.Filter { +func (self *Ethereum) GetFilter(id int) *chain.Filter { self.filterMu.RLock() defer self.filterMu.RUnlock() return self.filters[id] @@ -615,10 +615,10 @@ func (self *Ethereum) GetFilter(id int) *ethchain.Filter { func (self *Ethereum) filterLoop() { // Subscribe to events - events := self.eventMux.Subscribe(ethchain.NewBlockEvent{}, ethstate.Messages(nil)) + events := self.eventMux.Subscribe(chain.NewBlockEvent{}, ethstate.Messages(nil)) for event := range events.Chan() { switch event := event.(type) { - case ethchain.NewBlockEvent: + case chain.NewBlockEvent: self.filterMu.RLock() for _, filter := range self.filters { if filter.BlockCallback != nil { diff --git a/ethminer/miner.go b/ethminer/miner.go index 571b92ce08..c2e973f321 100644 --- a/ethminer/miner.go +++ b/ethminer/miner.go @@ -4,7 +4,7 @@ import ( "bytes" "sort" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethwire" "github.com/ethereum/go-ethereum/event" @@ -13,12 +13,12 @@ import ( var logger = ethlog.NewLogger("MINER") type Miner struct { - pow ethchain.PoW - ethereum ethchain.EthManager + pow chain.PoW + ethereum chain.EthManager coinbase []byte - txs ethchain.Transactions - uncles []*ethchain.Block - block *ethchain.Block + txs chain.Transactions + uncles []*chain.Block + block *chain.Block events event.Subscription powQuitChan chan struct{} @@ -37,13 +37,13 @@ type Event struct { Miner *Miner } -func (self *Miner) GetPow() ethchain.PoW { +func (self *Miner) GetPow() chain.PoW { return self.pow } -func NewDefaultMiner(coinbase []byte, ethereum ethchain.EthManager) *Miner { +func NewDefaultMiner(coinbase []byte, ethereum chain.EthManager) *Miner { miner := Miner{ - pow: ðchain.EasyPow{}, + pow: &chain.EasyPow{}, ethereum: ethereum, coinbase: coinbase, } @@ -64,7 +64,7 @@ func (miner *Miner) Start() { miner.block = miner.ethereum.ChainManager().NewBlock(miner.coinbase) mux := miner.ethereum.EventMux() - miner.events = mux.Subscribe(ethchain.NewBlockEvent{}, ethchain.TxPreEvent{}) + miner.events = mux.Subscribe(chain.NewBlockEvent{}, chain.TxPreEvent{}) // Prepare inital block //miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State()) @@ -87,7 +87,7 @@ func (miner *Miner) listener() { select { case event := <-miner.events.Chan(): switch event := event.(type) { - case ethchain.NewBlockEvent: + case chain.NewBlockEvent: miner.stopMining() block := event.Block @@ -97,7 +97,7 @@ func (miner *Miner) listener() { //logger.Infoln("New top block found resetting state") // Filter out which Transactions we have that were not in this block - var newtxs []*ethchain.Transaction + var newtxs []*chain.Transaction for _, tx := range miner.txs { found := false for _, othertx := range block.Transactions() { @@ -118,7 +118,7 @@ func (miner *Miner) listener() { } miner.startMining() - case ethchain.TxPreEvent: + case chain.TxPreEvent: miner.stopMining() found := false @@ -171,7 +171,7 @@ func (self *Miner) mineNewBlock() { } // Sort the transactions by nonce in case of odd network propagation - sort.Sort(ethchain.TxByNonce{self.txs}) + sort.Sort(chain.TxByNonce{self.txs}) // Accumulate all valid transactions and apply them to the new state // Error may be ignored. It's not important during mining @@ -208,7 +208,7 @@ func (self *Miner) mineNewBlock() { logger.Infoln(self.block) // Gather the new batch of transactions currently in the tx pool self.txs = self.ethereum.TxPool().CurrentTransactions() - self.ethereum.EventMux().Post(ethchain.NewBlockEvent{self.block}) + self.ethereum.EventMux().Post(chain.NewBlockEvent{self.block}) } // Continue mining on the next block diff --git a/ethpipe/js_pipe.go b/ethpipe/js_pipe.go index 4b4369768d..ee4637d8fa 100644 --- a/ethpipe/js_pipe.go +++ b/ethpipe/js_pipe.go @@ -5,7 +5,7 @@ import ( "encoding/json" "sync/atomic" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethcrypto" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" @@ -15,7 +15,7 @@ type JSPipe struct { *Pipe } -func NewJSPipe(eth ethchain.EthManager) *JSPipe { +func NewJSPipe(eth chain.EthManager) *JSPipe { return &JSPipe{New(eth)} } @@ -63,7 +63,7 @@ func (self *JSPipe) PeerCount() int { func (self *JSPipe) Peers() []JSPeer { var peers []JSPeer for peer := self.obj.Peers().Front(); peer != nil; peer = peer.Next() { - p := peer.Value.(ethchain.Peer) + p := peer.Value.(chain.Peer) // we only want connected peers if atomic.LoadInt32(p.Connected()) != 0 { peers = append(peers, *NewJSPeer(p)) @@ -209,7 +209,7 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr gas = ethutil.Big(gasStr) gasPrice = ethutil.Big(gasPriceStr) data []byte - tx *ethchain.Transaction + tx *chain.Transaction ) if ethutil.IsHex(codeStr) { @@ -219,9 +219,9 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr } if contractCreation { - tx = ethchain.NewContractCreationTx(value, gas, gasPrice, data) + tx = chain.NewContractCreationTx(value, gas, gasPrice, data) } else { - tx = ethchain.NewTransactionMessage(hash, value, gas, gasPrice, data) + tx = chain.NewTransactionMessage(hash, value, gas, gasPrice, data) } acc := self.obj.StateManager().TransState().GetOrNewStateObject(keyPair.Address()) @@ -240,7 +240,7 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr } func (self *JSPipe) PushTx(txStr string) (*JSReceipt, error) { - tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(txStr)) + tx := chain.NewTransactionFromBytes(ethutil.Hex2Bytes(txStr)) self.obj.TxPool().QueueTransaction(tx) return NewJSReciept(tx.CreatesContract(), tx.CreationAddress(self.World().State()), tx.Hash(), tx.Sender()), nil } diff --git a/ethpipe/js_types.go b/ethpipe/js_types.go index 956a49ab77..94019f2757 100644 --- a/ethpipe/js_types.go +++ b/ethpipe/js_types.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethcrypto" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" @@ -14,7 +14,7 @@ import ( // Block interface exposed to QML type JSBlock struct { //Transactions string `json:"transactions"` - ref *ethchain.Block + ref *chain.Block Size string `json:"size"` Number int `json:"number"` Hash string `json:"hash"` @@ -29,7 +29,7 @@ type JSBlock struct { } // Creates a new QML Block from a chain block -func NewJSBlock(block *ethchain.Block) *JSBlock { +func NewJSBlock(block *chain.Block) *JSBlock { if block == nil { return &JSBlock{} } @@ -75,7 +75,7 @@ func (self *JSBlock) GetTransaction(hash string) *JSTransaction { } type JSTransaction struct { - ref *ethchain.Transaction + ref *chain.Transaction Value string `json:"value"` Gas string `json:"gas"` @@ -90,7 +90,7 @@ type JSTransaction struct { Confirmations int `json:"confirmations"` } -func NewJSTx(tx *ethchain.Transaction, state *ethstate.State) *JSTransaction { +func NewJSTx(tx *chain.Transaction, state *ethstate.State) *JSTransaction { hash := ethutil.Bytes2Hex(tx.Hash()) receiver := ethutil.Bytes2Hex(tx.Recipient) if receiver == "0000000000000000000000000000000000000000" { @@ -101,7 +101,7 @@ func NewJSTx(tx *ethchain.Transaction, state *ethstate.State) *JSTransaction { var data string if tx.CreatesContract() { - data = strings.Join(ethchain.Disassemble(tx.Data), "\n") + data = strings.Join(chain.Disassemble(tx.Data), "\n") } else { data = ethutil.Bytes2Hex(tx.Data) } @@ -150,7 +150,7 @@ func NewPReciept(contractCreation bool, creationAddress, hash, address []byte) * // Peer interface exposed to QML type JSPeer struct { - ref *ethchain.Peer + ref *chain.Peer Inbound bool `json:"isInbound"` LastSend int64 `json:"lastSend"` LastPong int64 `json:"lastPong"` @@ -162,7 +162,7 @@ type JSPeer struct { Caps string `json:"caps"` } -func NewJSPeer(peer ethchain.Peer) *JSPeer { +func NewJSPeer(peer chain.Peer) *JSPeer { if peer == nil { return nil } diff --git a/ethpipe/pipe.go b/ethpipe/pipe.go index 13085c887f..7dd6ae2626 100644 --- a/ethpipe/pipe.go +++ b/ethpipe/pipe.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethcrypto" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethstate" @@ -19,15 +19,15 @@ type VmVars struct { } type Pipe struct { - obj ethchain.EthManager - stateManager *ethchain.StateManager - blockChain *ethchain.ChainManager + obj chain.EthManager + stateManager *chain.StateManager + blockChain *chain.ChainManager world *World Vm VmVars } -func New(obj ethchain.EthManager) *Pipe { +func New(obj chain.EthManager) *Pipe { pipe := &Pipe{ obj: obj, stateManager: obj.StateManager(), @@ -68,7 +68,7 @@ func (self *Pipe) ExecuteObject(object *Object, data []byte, value, gas, price * return ret, err } -func (self *Pipe) Block(hash []byte) *ethchain.Block { +func (self *Pipe) Block(hash []byte) *chain.Block { return self.blockChain.GetBlock(hash) } @@ -111,7 +111,7 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price contractCreation = true } - var tx *ethchain.Transaction + var tx *chain.Transaction // Compile and assemble the given data if contractCreation { script, err := ethutil.Compile(string(data), false) @@ -119,7 +119,7 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price return nil, err } - tx = ethchain.NewContractCreationTx(value.BigInt(), gas.BigInt(), price.BigInt(), script) + tx = chain.NewContractCreationTx(value.BigInt(), gas.BigInt(), price.BigInt(), script) } else { data := ethutil.StringToByteFunc(string(data), func(s string) (ret []byte) { slice := strings.Split(s, "\n") @@ -130,7 +130,7 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price return }) - tx = ethchain.NewTransactionMessage(hash, value.BigInt(), gas.BigInt(), price.BigInt(), data) + tx = chain.NewTransactionMessage(hash, value.BigInt(), gas.BigInt(), price.BigInt(), data) } acc := self.stateManager.TransState().GetOrNewStateObject(key.Address()) @@ -151,7 +151,7 @@ func (self *Pipe) Transact(key *ethcrypto.KeyPair, rec []byte, value, gas, price return tx.Hash(), nil } -func (self *Pipe) PushTx(tx *ethchain.Transaction) ([]byte, error) { +func (self *Pipe) PushTx(tx *chain.Transaction) ([]byte, error) { self.obj.TxPool().QueueTransaction(tx) if tx.Recipient == nil { addr := tx.CreationAddress(self.World().State()) diff --git a/ethpipe/vm_env.go b/ethpipe/vm_env.go index eb1190cf1f..baab67b283 100644 --- a/ethpipe/vm_env.go +++ b/ethpipe/vm_env.go @@ -3,19 +3,19 @@ package ethpipe import ( "math/big" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/vm" ) type VMEnv struct { state *ethstate.State - block *ethchain.Block + block *chain.Block value *big.Int sender []byte } -func NewEnv(state *ethstate.State, block *ethchain.Block, value *big.Int, sender []byte) *VMEnv { +func NewEnv(state *ethstate.State, block *chain.Block, value *big.Int, sender []byte) *VMEnv { return &VMEnv{ state: state, block: block, diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 6c5a873386..36850021d3 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -8,7 +8,7 @@ import ( "path/filepath" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" @@ -62,7 +62,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { // Subscribe to events mux := ethereum.EventMux() - re.events = mux.Subscribe(ethchain.NewBlockEvent{}) + re.events = mux.Subscribe(chain.NewBlockEvent{}) // We have to make sure that, whoever calls this, calls "Stop" go re.mainLoop() @@ -130,7 +130,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { var state *ethstate.State if len(call.ArgumentList) > 0 { - var block *ethchain.Block + var block *chain.Block if call.Argument(0).IsNumber() { num, _ := call.Argument(0).ToInteger() block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num)) diff --git a/peer.go b/peer.go index 31bee19378..ab25e57091 100644 --- a/peer.go +++ b/peer.go @@ -12,7 +12,7 @@ import ( "sync/atomic" "time" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethwire" @@ -155,7 +155,7 @@ type Peer struct { pingTime time.Duration pingStartTime time.Time - lastRequestedBlock *ethchain.Block + lastRequestedBlock *chain.Block protocolCaps *ethutil.Value } @@ -378,7 +378,7 @@ func formatMessage(msg *ethwire.Msg) (ret string) { case ethwire.MsgPeersTy: ret += fmt.Sprintf("(%d entries)", msg.Data.Len()) case ethwire.MsgBlockTy: - b1, b2 := ethchain.NewBlockFromRlpValue(msg.Data.Get(0)), ethchain.NewBlockFromRlpValue(msg.Data.Get(msg.Data.Len()-1)) + b1, b2 := chain.NewBlockFromRlpValue(msg.Data.Get(0)), ethchain.NewBlockFromRlpValue(msg.Data.Get(msg.Data.Len()-1)) ret += fmt.Sprintf("(%d entries) %x - %x", msg.Data.Len(), b1.Hash()[0:4], b2.Hash()[0:4]) case ethwire.MsgBlockHashesTy: h1, h2 := msg.Data.Get(0).Bytes(), msg.Data.Get(msg.Data.Len()-1).Bytes() @@ -429,7 +429,7 @@ func (p *Peer) HandleInbound() { // in the TxPool where it will undergo validation and // processing when a new block is found for i := 0; i < msg.Data.Len(); i++ { - tx := ethchain.NewTransactionFromValue(msg.Data.Get(i)) + tx := chain.NewTransactionFromValue(msg.Data.Get(i)) p.ethereum.TxPool().QueueTransaction(tx) } case ethwire.MsgGetPeersTy: @@ -535,7 +535,7 @@ func (p *Peer) HandleInbound() { it := msg.Data.NewIterator() for it.Next() { - block := ethchain.NewBlockFromRlpValue(it.Value()) + block := chain.NewBlockFromRlpValue(it.Value()) blockPool.Add(block, p) p.lastBlockReceived = time.Now() @@ -543,7 +543,7 @@ func (p *Peer) HandleInbound() { case ethwire.MsgNewBlockTy: var ( blockPool = p.ethereum.blockPool - block = ethchain.NewBlockFromRlpValue(msg.Data.Get(0)) + block = chain.NewBlockFromRlpValue(msg.Data.Get(0)) td = msg.Data.Get(1).BigInt() ) diff --git a/ui/filter.go b/ui/filter.go index ad29abbc55..84209861ea 100644 --- a/ui/filter.go +++ b/ui/filter.go @@ -1,12 +1,12 @@ package ui import ( - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethutil" ) -func NewFilterFromMap(object map[string]interface{}, eth ethchain.EthManager) *ethchain.Filter { - filter := ethchain.NewFilter(eth) +func NewFilterFromMap(object map[string]interface{}, eth chain.EthManager) *chain.Filter { + filter := chain.NewFilter(eth) if object["earliest"] != nil { val := ethutil.NewValue(object["earliest"]) @@ -46,7 +46,7 @@ func NewFilterFromMap(object map[string]interface{}, eth ethchain.EthManager) *e } // Conversion methodn -func mapToAccountChange(m map[string]interface{}) (d ethchain.AccountChange) { +func mapToAccountChange(m map[string]interface{}) (d chain.AccountChange) { if str, ok := m["id"].(string); ok { d.Address = ethutil.Hex2Bytes(str) } @@ -60,9 +60,9 @@ func mapToAccountChange(m map[string]interface{}) (d ethchain.AccountChange) { // data can come in in the following formats: // ["aabbccdd", {id: "ccddee", at: "11223344"}], "aabbcc", {id: "ccddee", at: "1122"} -func makeAltered(v interface{}) (d []ethchain.AccountChange) { +func makeAltered(v interface{}) (d []chain.AccountChange) { if str, ok := v.(string); ok { - d = append(d, ethchain.AccountChange{ethutil.Hex2Bytes(str), nil}) + d = append(d, chain.AccountChange{ethutil.Hex2Bytes(str), nil}) } else if obj, ok := v.(map[string]interface{}); ok { d = append(d, mapToAccountChange(obj)) } else if slice, ok := v.([]interface{}); ok { diff --git a/ui/qt/filter.go b/ui/qt/filter.go index 1fd99e78eb..96c3ab3a32 100644 --- a/ui/qt/filter.go +++ b/ui/qt/filter.go @@ -3,12 +3,12 @@ package qt import ( "fmt" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ui" "gopkg.in/qml.v1" ) -func NewFilterFromMap(object map[string]interface{}, eth ethchain.EthManager) *ethchain.Filter { +func NewFilterFromMap(object map[string]interface{}, eth chain.EthManager) *chain.Filter { filter := ui.NewFilterFromMap(object, eth) if object["altered"] != nil { @@ -18,7 +18,7 @@ func NewFilterFromMap(object map[string]interface{}, eth ethchain.EthManager) *e return filter } -func makeAltered(v interface{}) (d []ethchain.AccountChange) { +func makeAltered(v interface{}) (d []chain.AccountChange) { if qList, ok := v.(*qml.List); ok { var s []interface{} qList.Convert(&s) diff --git a/utils/vm_env.go b/utils/vm_env.go index 9d9bbf4ec7..0a7b589ee6 100644 --- a/utils/vm_env.go +++ b/utils/vm_env.go @@ -3,20 +3,20 @@ package utils import ( "math/big" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/vm" ) type VMEnv struct { state *ethstate.State - block *ethchain.Block + block *chain.Block transactor []byte value *big.Int } -func NewEnv(state *ethstate.State, block *ethchain.Block, transactor []byte, value *big.Int) *VMEnv { +func NewEnv(state *ethstate.State, block *chain.Block, transactor []byte, value *big.Int) *VMEnv { return &VMEnv{ state: state, block: block,