Moved ethchain to chain

This commit is contained in:
obscuren 2014-10-31 10:59:17 +01:00
parent 8e0a39f33f
commit 3ee0461cb5
47 changed files with 142 additions and 142 deletions

@ -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 {

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"fmt"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"bytes"

@ -1,4 +1,4 @@
package ethchain
package chain
type BloomFilter struct {
bin []byte

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"math/big"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"testing"

@ -1,4 +1,4 @@
package ethchain
package chain
import "testing"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"bytes"

@ -0,0 +1 @@
package chain

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"hash"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"math/big"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"github.com/ethereum/go-ethereum/ethtrie"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"fmt"

@ -1,4 +1,4 @@
package ethchain
package chain
// TxPreEvent is posted when a transaction enters the transaction pool.
type TxPreEvent struct{ Tx *Transaction }

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"math/big"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"bytes"

@ -1,4 +1,4 @@
package ethchain
package chain
import "testing"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"math/big"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"container/list"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"bytes"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"fmt"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"bytes"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"bytes"

@ -0,0 +1 @@
package chain

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"fmt"

@ -1,4 +1,4 @@
package ethchain
package chain
import (
"math/big"

@ -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))

@ -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)
}

@ -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:

@ -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())

@ -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 := &ethpipe.JSBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())}
app.webView.Call("onNewBlockCb", b)
}

@ -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 := &ethpipe.JSBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())}
app.win.Call("onNewBlockCb", pblock)
}

@ -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)

@ -1 +0,0 @@
package ethchain

@ -1 +0,0 @@
package ethchain

@ -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 {

@ -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: &ethchain.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

@ -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
}

@ -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
}

@ -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())

@ -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,

@ -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))

12
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()
)

@ -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 {

@ -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)

@ -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,