Renamed chain => core

This commit is contained in:
obscuren 2014-12-04 10:28:02 +01:00
parent b6cb5272de
commit 9008b155d3
45 changed files with 112 additions and 160 deletions

View File

@ -9,7 +9,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/wire" "github.com/ethereum/go-ethereum/wire"

View File

@ -21,8 +21,9 @@ import (
"encoding/json" "encoding/json"
"os" "os"
"strconv" "strconv"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
) )

View File

@ -24,8 +24,8 @@ import (
"strings" "strings"
"unicode" "unicode"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm" "github.com/ethereum/go-ethereum/vm"
@ -81,7 +81,7 @@ func (self *DebuggerWindow) SetData(data string) {
func (self *DebuggerWindow) SetAsm(data []byte) { func (self *DebuggerWindow) SetAsm(data []byte) {
self.win.Root().Call("clearAsm") self.win.Root().Call("clearAsm")
dis := chain.Disassemble(data) dis := core.Disassemble(data)
for _, str := range dis { for _, str := range dis {
self.win.Root().Call("setAsm", str) self.win.Root().Call("setAsm", str)
} }

View File

@ -20,8 +20,8 @@ package main
import ( import (
"encoding/json" "encoding/json"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/javascript" "github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
@ -45,12 +45,12 @@ type AppContainer interface {
type ExtApplication struct { type ExtApplication struct {
*xeth.JSXEth *xeth.JSXEth
eth chain.EthManager eth core.EthManager
events event.Subscription events event.Subscription
watcherQuitChan chan bool watcherQuitChan chan bool
filters map[string]*chain.Filter filters map[string]*core.Filter
container AppContainer container AppContainer
lib *UiLib lib *UiLib
@ -61,7 +61,7 @@ func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
JSXEth: xeth.NewJSXEth(lib.eth), JSXEth: xeth.NewJSXEth(lib.eth),
eth: lib.eth, eth: lib.eth,
watcherQuitChan: make(chan bool), watcherQuitChan: make(chan bool),
filters: make(map[string]*chain.Filter), filters: make(map[string]*core.Filter),
container: container, container: container,
lib: lib, lib: lib,
} }
@ -81,7 +81,7 @@ func (app *ExtApplication) run() {
// Subscribe to events // Subscribe to events
mux := app.lib.eth.EventMux() mux := app.lib.eth.EventMux()
app.events = mux.Subscribe(chain.NewBlockEvent{}, state.Messages(nil)) app.events = mux.Subscribe(core.NewBlockEvent{}, state.Messages(nil))
// Call the main loop // Call the main loop
go app.mainLoop() go app.mainLoop()
@ -107,7 +107,7 @@ func (app *ExtApplication) stop() {
func (app *ExtApplication) mainLoop() { func (app *ExtApplication) mainLoop() {
for ev := range app.events.Chan() { for ev := range app.events.Chan() {
switch ev := ev.(type) { switch ev := ev.(type) {
case chain.NewBlockEvent: case core.NewBlockEvent:
app.container.NewBlock(ev.Block) app.container.NewBlock(ev.Block)
case state.Messages: case state.Messages:

View File

@ -31,8 +31,8 @@ import (
"time" "time"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
@ -413,9 +413,9 @@ func (gui *Gui) update() {
events := gui.eth.EventMux().Subscribe( events := gui.eth.EventMux().Subscribe(
eth.ChainSyncEvent{}, eth.ChainSyncEvent{},
eth.PeerListEvent{}, eth.PeerListEvent{},
chain.NewBlockEvent{}, core.NewBlockEvent{},
chain.TxPreEvent{}, core.TxPreEvent{},
chain.TxPostEvent{}, core.TxPostEvent{},
) )
// nameReg := gui.pipe.World().Config().Get("NameReg") // nameReg := gui.pipe.World().Config().Get("NameReg")
@ -430,13 +430,13 @@ func (gui *Gui) update() {
return return
} }
switch ev := ev.(type) { switch ev := ev.(type) {
case chain.NewBlockEvent: case core.NewBlockEvent:
gui.processBlock(ev.Block, false) gui.processBlock(ev.Block, false)
if bytes.Compare(ev.Block.Coinbase, gui.address()) == 0 { if bytes.Compare(ev.Block.Coinbase, gui.address()) == 0 {
gui.setWalletValue(gui.eth.BlockManager().CurrentState().GetAccount(gui.address()).Balance(), nil) gui.setWalletValue(gui.eth.BlockManager().CurrentState().GetAccount(gui.address()).Balance(), nil)
} }
case chain.TxPreEvent: case core.TxPreEvent:
tx := ev.Tx tx := ev.Tx
object := state.GetAccount(gui.address()) object := state.GetAccount(gui.address())
@ -449,7 +449,7 @@ func (gui *Gui) update() {
gui.setWalletValue(object.Balance(), unconfirmedFunds) gui.setWalletValue(object.Balance(), unconfirmedFunds)
gui.insertTransaction("pre", tx) gui.insertTransaction("pre", tx)
case chain.TxPostEvent: case core.TxPostEvent:
tx := ev.Tx tx := ev.Tx
object := state.GetAccount(gui.address()) object := state.GetAccount(gui.address())

View File

@ -26,7 +26,8 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/javascript" "github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"

View File

@ -20,7 +20,8 @@ package main
import ( import (
"fmt" "fmt"
"runtime" "runtime"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/xeth" "github.com/ethereum/go-ethereum/xeth"

View File

@ -25,8 +25,8 @@ import (
"strings" "strings"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/javascript" "github.com/ethereum/go-ethereum/javascript"
@ -231,7 +231,7 @@ func (self *UiLib) NewFilter(object map[string]interface{}) (id int) {
} }
func (self *UiLib) NewFilterString(typ string) (id int) { func (self *UiLib) NewFilterString(typ string) (id int) {
filter := chain.NewFilter(self.eth) filter := core.NewFilter(self.eth)
filter.BlockCallback = func(block *types.Block) { filter.BlockCallback = func(block *types.Block) {
if self.win != nil && self.win.Root() != nil { if self.win != nil && self.win.Root() != nil {
self.win.Root().Call("invokeFilterCallback", "{}", id) self.win.Root().Call("invokeFilterCallback", "{}", id)

View File

@ -3,8 +3,8 @@ package utils
import ( import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm" "github.com/ethereum/go-ethereum/vm"
) )
@ -48,10 +48,10 @@ func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
return vm.Transfer(from, to, amount) return vm.Transfer(from, to, amount)
} }
func (self *VMEnv) vm(addr, data []byte, gas, price, value *big.Int) *chain.Execution { func (self *VMEnv) vm(addr, data []byte, gas, price, value *big.Int) *core.Execution {
evm := vm.New(self, vm.DebugVmTy) evm := vm.New(self, vm.DebugVmTy)
return chain.NewExecution(evm, addr, data, gas, price, value) return core.NewExecution(evm, addr, data, gas, price, value)
} }
func (self *VMEnv) Call(caller vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) { func (self *VMEnv) Call(caller vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) {

View File

View File

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

View File

@ -1,4 +1,4 @@
package chain package core
import ( import (
"bytes" "bytes"
@ -9,7 +9,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"

View File

@ -1,10 +1,10 @@
package chain package core
import ( import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"

View File

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

View File

@ -1,4 +1,4 @@
package chain package core
import ( import (
"hash" "hash"
@ -6,7 +6,7 @@ import (
"math/rand" "math/rand"
"time" "time"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"

View File

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

View File

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

View File

@ -1,6 +1,6 @@
package chain package core
import "github.com/ethereum/go-ethereum/chain/types" import "github.com/ethereum/go-ethereum/core/types"
// TxPreEvent is posted when a transaction enters the transaction pool. // TxPreEvent is posted when a transaction enters the transaction pool.
type TxPreEvent struct{ Tx *types.Transaction } type TxPreEvent struct{ Tx *types.Transaction }

View File

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

View File

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

View File

@ -1,11 +1,11 @@
package chain package core
import ( import (
"bytes" "bytes"
"math" "math"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
) )

View File

@ -1,4 +1,4 @@
package chain package core
// import "testing" // import "testing"

View File

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

View File

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

View File

@ -1,10 +1,10 @@
package chain package core
import ( import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm" "github.com/ethereum/go-ethereum/vm"
) )

View File

@ -1,4 +1,4 @@
package chain package core
import ( import (
"bytes" "bytes"
@ -7,7 +7,7 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/wire" "github.com/ethereum/go-ethereum/wire"

View File

@ -1,9 +1,9 @@
package chain package core
import ( import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm" "github.com/ethereum/go-ethereum/vm"
) )

View File

@ -14,7 +14,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
@ -50,12 +50,12 @@ type Ethereum struct {
// DB interface // DB interface
db ethutil.Database db ethutil.Database
// State manager for processing new blocks and managing the over all states // State manager for processing new blocks and managing the over all states
blockManager *chain.BlockManager blockManager *core.BlockManager
// The transaction pool. Transaction can be pushed on this pool // The transaction pool. Transaction can be pushed on this pool
// for later including in the blocks // for later including in the blocks
txPool *chain.TxPool txPool *core.TxPool
// The canonical chain // The canonical chain
blockChain *chain.ChainManager blockChain *core.ChainManager
// The block pool // The block pool
blockPool *BlockPool blockPool *BlockPool
// Eventer // Eventer
@ -94,7 +94,7 @@ type Ethereum struct {
filterMu sync.RWMutex filterMu sync.RWMutex
filterId int filterId int
filters map[int]*chain.Filter filters map[int]*core.Filter
} }
func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *crypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) { func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *crypto.KeyManager, caps Caps, usePnp bool) (*Ethereum, error) {
@ -124,13 +124,13 @@ func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *cr
keyManager: keyManager, keyManager: keyManager,
clientIdentity: clientIdentity, clientIdentity: clientIdentity,
isUpToDate: true, isUpToDate: true,
filters: make(map[int]*chain.Filter), filters: make(map[int]*core.Filter),
} }
ethereum.blockPool = NewBlockPool(ethereum) ethereum.blockPool = NewBlockPool(ethereum)
ethereum.txPool = chain.NewTxPool(ethereum) ethereum.txPool = core.NewTxPool(ethereum)
ethereum.blockChain = chain.NewChainManager(ethereum.EventMux()) ethereum.blockChain = core.NewChainManager(ethereum.EventMux())
ethereum.blockManager = chain.NewBlockManager(ethereum) ethereum.blockManager = core.NewBlockManager(ethereum)
ethereum.blockChain.SetProcessor(ethereum.blockManager) ethereum.blockChain.SetProcessor(ethereum.blockManager)
// Start the tx pool // Start the tx pool
@ -147,15 +147,15 @@ func (s *Ethereum) ClientIdentity() wire.ClientIdentity {
return s.clientIdentity return s.clientIdentity
} }
func (s *Ethereum) ChainManager() *chain.ChainManager { func (s *Ethereum) ChainManager() *core.ChainManager {
return s.blockChain return s.blockChain
} }
func (s *Ethereum) BlockManager() *chain.BlockManager { func (s *Ethereum) BlockManager() *core.BlockManager {
return s.blockManager return s.blockManager
} }
func (s *Ethereum) TxPool() *chain.TxPool { func (s *Ethereum) TxPool() *core.TxPool {
return s.txPool return s.txPool
} }
func (s *Ethereum) BlockPool() *BlockPool { func (s *Ethereum) BlockPool() *BlockPool {
@ -591,7 +591,7 @@ out:
// InstallFilter adds filter for blockchain events. // InstallFilter adds filter for blockchain events.
// The filter's callbacks will run for matching blocks and messages. // The filter's callbacks will run for matching blocks and messages.
// The filter should not be modified after it has been installed. // The filter should not be modified after it has been installed.
func (self *Ethereum) InstallFilter(filter *chain.Filter) (id int) { func (self *Ethereum) InstallFilter(filter *core.Filter) (id int) {
self.filterMu.Lock() self.filterMu.Lock()
id = self.filterId id = self.filterId
self.filters[id] = filter self.filters[id] = filter
@ -608,7 +608,7 @@ func (self *Ethereum) UninstallFilter(id int) {
// GetFilter retrieves a filter installed using InstallFilter. // GetFilter retrieves a filter installed using InstallFilter.
// The filter may not be modified. // The filter may not be modified.
func (self *Ethereum) GetFilter(id int) *chain.Filter { func (self *Ethereum) GetFilter(id int) *core.Filter {
self.filterMu.RLock() self.filterMu.RLock()
defer self.filterMu.RUnlock() defer self.filterMu.RUnlock()
return self.filters[id] return self.filters[id]
@ -616,10 +616,10 @@ func (self *Ethereum) GetFilter(id int) *chain.Filter {
func (self *Ethereum) filterLoop() { func (self *Ethereum) filterLoop() {
// Subscribe to events // Subscribe to events
events := self.eventMux.Subscribe(chain.NewBlockEvent{}, state.Messages(nil)) events := self.eventMux.Subscribe(core.NewBlockEvent{}, state.Messages(nil))
for event := range events.Chan() { for event := range events.Chan() {
switch event := event.(type) { switch event := event.(type) {
case chain.NewBlockEvent: case core.NewBlockEvent:
self.filterMu.RLock() self.filterMu.RLock()
for _, filter := range self.filters { for _, filter := range self.filters {
if filter.BlockCallback != nil { if filter.BlockCallback != nil {

View File

@ -8,9 +8,9 @@ import (
"path/filepath" "path/filepath"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
@ -63,7 +63,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
// Subscribe to events // Subscribe to events
mux := ethereum.EventMux() mux := ethereum.EventMux()
re.events = mux.Subscribe(chain.NewBlockEvent{}) re.events = mux.Subscribe(core.NewBlockEvent{})
// We have to make sure that, whoever calls this, calls "Stop" // We have to make sure that, whoever calls this, calls "Stop"
go re.mainLoop() go re.mainLoop()

View File

@ -30,8 +30,8 @@ import (
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/wire" "github.com/ethereum/go-ethereum/wire"
@ -59,7 +59,7 @@ type Miner struct {
localTxs map[int]*LocalTx localTxs map[int]*LocalTx
localTxId int localTxId int
pow chain.PoW pow core.PoW
quitCh chan struct{} quitCh chan struct{}
powQuitCh chan struct{} powQuitCh chan struct{}
@ -74,7 +74,7 @@ func New(coinbase []byte, eth *eth.Ethereum) *Miner {
return &Miner{ return &Miner{
eth: eth, eth: eth,
powQuitCh: make(chan struct{}), powQuitCh: make(chan struct{}),
pow: &chain.EasyPow{}, pow: &core.EasyPow{},
mining: false, mining: false,
localTxs: make(map[int]*LocalTx), localTxs: make(map[int]*LocalTx),
MinAcceptedGasPrice: big.NewInt(10000000000000), MinAcceptedGasPrice: big.NewInt(10000000000000),
@ -82,7 +82,7 @@ func New(coinbase []byte, eth *eth.Ethereum) *Miner {
} }
} }
func (self *Miner) GetPow() chain.PoW { func (self *Miner) GetPow() core.PoW {
return self.pow return self.pow
} }
@ -116,7 +116,7 @@ func (self *Miner) Start() {
self.powQuitCh = make(chan struct{}) self.powQuitCh = make(chan struct{})
mux := self.eth.EventMux() mux := self.eth.EventMux()
self.events = mux.Subscribe(chain.NewBlockEvent{}, chain.TxPreEvent{}, &LocalTx{}) self.events = mux.Subscribe(core.NewBlockEvent{}, core.TxPreEvent{}, &LocalTx{})
go self.update() go self.update()
go self.mine() go self.mine()
@ -147,7 +147,7 @@ out:
select { select {
case event := <-self.events.Chan(): case event := <-self.events.Chan():
switch event := event.(type) { switch event := event.(type) {
case chain.NewBlockEvent: case core.NewBlockEvent:
block := event.Block block := event.Block
if self.eth.ChainManager().HasBlock(block.Hash()) { if self.eth.ChainManager().HasBlock(block.Hash()) {
self.reset() self.reset()
@ -156,7 +156,7 @@ out:
} else if true { } else if true {
// do uncle stuff // do uncle stuff
} }
case chain.TxPreEvent, *LocalTx: case core.TxPreEvent, *LocalTx:
self.reset() self.reset()
go self.mine() go self.mine()
} }

View File

@ -12,7 +12,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/wire" "github.com/ethereum/go-ethereum/wire"

View File

@ -1,12 +1,12 @@
package ui package ui
import ( import (
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
) )
func NewFilterFromMap(object map[string]interface{}, eth chain.EthManager) *chain.Filter { func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.Filter {
filter := chain.NewFilter(eth) filter := core.NewFilter(eth)
if object["earliest"] != nil { if object["earliest"] != nil {
val := ethutil.NewValue(object["earliest"]) val := ethutil.NewValue(object["earliest"])
@ -46,7 +46,7 @@ func NewFilterFromMap(object map[string]interface{}, eth chain.EthManager) *chai
} }
// Conversion methodn // Conversion methodn
func mapToAccountChange(m map[string]interface{}) (d chain.AccountChange) { func mapToAccountChange(m map[string]interface{}) (d core.AccountChange) {
if str, ok := m["id"].(string); ok { if str, ok := m["id"].(string); ok {
d.Address = ethutil.Hex2Bytes(str) d.Address = ethutil.Hex2Bytes(str)
} }
@ -60,9 +60,9 @@ func mapToAccountChange(m map[string]interface{}) (d chain.AccountChange) {
// data can come in in the following formats: // data can come in in the following formats:
// ["aabbccdd", {id: "ccddee", at: "11223344"}], "aabbcc", {id: "ccddee", at: "1122"} // ["aabbccdd", {id: "ccddee", at: "11223344"}], "aabbcc", {id: "ccddee", at: "1122"}
func makeAltered(v interface{}) (d []chain.AccountChange) { func makeAltered(v interface{}) (d []core.AccountChange) {
if str, ok := v.(string); ok { if str, ok := v.(string); ok {
d = append(d, chain.AccountChange{ethutil.Hex2Bytes(str), nil}) d = append(d, core.AccountChange{ethutil.Hex2Bytes(str), nil})
} else if obj, ok := v.(map[string]interface{}); ok { } else if obj, ok := v.(map[string]interface{}); ok {
d = append(d, mapToAccountChange(obj)) d = append(d, mapToAccountChange(obj))
} else if slice, ok := v.([]interface{}); ok { } else if slice, ok := v.([]interface{}); ok {

View File

@ -3,12 +3,12 @@ package qt
import ( import (
"fmt" "fmt"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/ui" "github.com/ethereum/go-ethereum/ui"
"gopkg.in/qml.v1" "gopkg.in/qml.v1"
) )
func NewFilterFromMap(object map[string]interface{}, eth chain.EthManager) *chain.Filter { func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.Filter {
filter := ui.NewFilterFromMap(object, eth) filter := ui.NewFilterFromMap(object, eth)
if object["altered"] != nil { if object["altered"] != nil {
@ -18,7 +18,7 @@ func NewFilterFromMap(object map[string]interface{}, eth chain.EthManager) *chai
return filter return filter
} }
func makeAltered(v interface{}) (d []chain.AccountChange) { func makeAltered(v interface{}) (d []core.AccountChange) {
if qList, ok := v.(*qml.List); ok { if qList, ok := v.(*qml.List); ok {
var s []interface{} var s []interface{}
qList.Convert(&s) qList.Convert(&s)

View File

@ -5,8 +5,8 @@ import (
"encoding/json" "encoding/json"
"sync/atomic" "sync/atomic"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
@ -16,7 +16,7 @@ type JSXEth struct {
*XEth *XEth
} }
func NewJSXEth(eth chain.EthManager) *JSXEth { func NewJSXEth(eth core.EthManager) *JSXEth {
return &JSXEth{New(eth)} return &JSXEth{New(eth)}
} }
@ -64,7 +64,7 @@ func (self *JSXEth) PeerCount() int {
func (self *JSXEth) Peers() []JSPeer { func (self *JSXEth) Peers() []JSPeer {
var peers []JSPeer var peers []JSPeer
for peer := self.obj.Peers().Front(); peer != nil; peer = peer.Next() { for peer := self.obj.Peers().Front(); peer != nil; peer = peer.Next() {
p := peer.Value.(chain.Peer) p := peer.Value.(core.Peer)
// we only want connected peers // we only want connected peers
if atomic.LoadInt32(p.Connected()) != 0 { if atomic.LoadInt32(p.Connected()) != 0 {
peers = append(peers, *NewJSPeer(p)) peers = append(peers, *NewJSPeer(p))
@ -220,57 +220,6 @@ func (self *JSXEth) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
} }
return ethutil.Bytes2Hex(tx.Hash()), nil return ethutil.Bytes2Hex(tx.Hash()), nil
/*
var hash []byte
var contractCreation bool
if len(toStr) == 0 {
contractCreation = true
} else {
// Check if an address is stored by this address
addr := self.World().Config().Get("NameReg").StorageString(toStr).Bytes()
if len(addr) > 0 {
hash = addr
} else {
hash = ethutil.Hex2Bytes(toStr)
}
}
var (
value = ethutil.Big(valueStr)
gas = ethutil.Big(gasStr)
gasPrice = ethutil.Big(gasPriceStr)
data []byte
tx *chain.Transaction
)
if ethutil.IsHex(codeStr) {
data = ethutil.Hex2Bytes(codeStr[2:])
} else {
data = ethutil.Hex2Bytes(codeStr)
}
if contractCreation {
tx = chain.NewContractCreationTx(value, gas, gasPrice, data)
} else {
tx = chain.NewTransactionMessage(hash, value, gas, gasPrice, data)
}
acc := self.obj.BlockManager().TransState().GetOrNewStateObject(keyPair.Address())
tx.Nonce = acc.Nonce
acc.Nonce += 1
self.obj.BlockManager().TransState().UpdateStateObject(acc)
tx.Sign(keyPair.PrivateKey)
self.obj.TxPool().QueueTransaction(tx)
if contractCreation {
pipelogger.Infof("Contract addr %x", tx.CreationAddress(self.World().State()))
}
return NewJSReciept(contractCreation, tx.CreationAddress(self.World().State()), tx.Hash(), keyPair.Address()), nil
*/
} }
func (self *JSXEth) PushTx(txStr string) (*JSReceipt, error) { func (self *JSXEth) PushTx(txStr string) (*JSReceipt, error) {

View File

@ -5,8 +5,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
@ -106,7 +106,7 @@ func NewJSTx(tx *types.Transaction, state *state.State) *JSTransaction {
var data string var data string
if tx.CreatesContract() { if tx.CreatesContract() {
data = strings.Join(chain.Disassemble(tx.Data), "\n") data = strings.Join(core.Disassemble(tx.Data), "\n")
} else { } else {
data = ethutil.Bytes2Hex(tx.Data) data = ethutil.Bytes2Hex(tx.Data)
} }
@ -155,7 +155,7 @@ func NewPReciept(contractCreation bool, creationAddress, hash, address []byte) *
// Peer interface exposed to QML // Peer interface exposed to QML
type JSPeer struct { type JSPeer struct {
ref *chain.Peer ref *core.Peer
Inbound bool `json:"isInbound"` Inbound bool `json:"isInbound"`
LastSend int64 `json:"lastSend"` LastSend int64 `json:"lastSend"`
LastPong int64 `json:"lastPong"` LastPong int64 `json:"lastPong"`
@ -167,7 +167,7 @@ type JSPeer struct {
Caps string `json:"caps"` Caps string `json:"caps"`
} }
func NewJSPeer(peer chain.Peer) *JSPeer { func NewJSPeer(peer core.Peer) *JSPeer {
if peer == nil { if peer == nil {
return nil return nil
} }

View File

@ -5,8 +5,8 @@ package xeth
*/ */
import ( import (
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
@ -20,15 +20,15 @@ type VmVars struct {
} }
type XEth struct { type XEth struct {
obj chain.EthManager obj core.EthManager
blockManager *chain.BlockManager blockManager *core.BlockManager
blockChain *chain.ChainManager blockChain *core.ChainManager
world *World world *World
Vm VmVars Vm VmVars
} }
func New(obj chain.EthManager) *XEth { func New(obj core.EthManager) *XEth {
pipe := &XEth{ pipe := &XEth{
obj: obj, obj: obj,
blockManager: obj.BlockManager(), blockManager: obj.BlockManager(),

View File

@ -3,8 +3,8 @@ package xeth
import ( import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm" "github.com/ethereum/go-ethereum/vm"
) )
@ -46,10 +46,10 @@ func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
return vm.Transfer(from, to, amount) return vm.Transfer(from, to, amount)
} }
func (self *VMEnv) vm(addr, data []byte, gas, price, value *big.Int) *chain.Execution { func (self *VMEnv) vm(addr, data []byte, gas, price, value *big.Int) *core.Execution {
evm := vm.New(self, vm.DebugVmTy) evm := vm.New(self, vm.DebugVmTy)
return chain.NewExecution(evm, addr, data, gas, price, value) return core.NewExecution(evm, addr, data, gas, price, value)
} }
func (self *VMEnv) Call(me vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) { func (self *VMEnv) Call(me vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) {