aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-16 23:46:29 +0800
committerzelig <viktor.tron@gmail.com>2015-03-16 23:46:29 +0800
commit5e7702fd050ed5520a03cc2cfc8b1f45a70f35fb (patch)
treed5ba6197a8c0c8e36bb92ee9fc8aad717cb2d178 /core
parent8393dab470c40678caf36ada82e312d29c4cf5c4 (diff)
parent22893b7ac925c49168c119f293ea8befc3aff5cc (diff)
downloadgo-tangerine-5e7702fd050ed5520a03cc2cfc8b1f45a70f35fb.tar.gz
go-tangerine-5e7702fd050ed5520a03cc2cfc8b1f45a70f35fb.tar.zst
go-tangerine-5e7702fd050ed5520a03cc2cfc8b1f45a70f35fb.zip
Merge remote-tracking branch 'upstream/develop' into frontier/js
Conflicts: cmd/ethereum/js.go javascript/types.go
Diffstat (limited to 'core')
-rw-r--r--core/asm.go6
-rw-r--r--core/block_processor.go12
-rw-r--r--core/chain_makers.go30
-rw-r--r--core/chain_manager.go36
-rw-r--r--core/genesis.go18
-rw-r--r--core/helper_test.go6
-rw-r--r--core/manager.go6
-rw-r--r--core/state_transition.go8
-rw-r--r--core/transaction_pool.go6
-rw-r--r--core/transaction_pool_test.go6
-rw-r--r--core/types/block.go10
-rw-r--r--core/types/bloom9.go8
-rw-r--r--core/types/bloom9_test.go4
-rw-r--r--core/types/derive_sha.go4
-rw-r--r--core/types/receipt.go14
-rw-r--r--core/types/transaction.go18
16 files changed, 96 insertions, 96 deletions
diff --git a/core/asm.go b/core/asm.go
index a8b3023f4..fc3493fe1 100644
--- a/core/asm.go
+++ b/core/asm.go
@@ -4,7 +4,7 @@ import (
"fmt"
"math/big"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/vm"
)
@@ -28,7 +28,7 @@ func Disassemble(script []byte) (asm []string) {
vm.PUSH16, vm.PUSH17, vm.PUSH18, vm.PUSH19, vm.PUSH20, vm.PUSH21, vm.PUSH22,
vm.PUSH23, vm.PUSH24, vm.PUSH25, vm.PUSH26, vm.PUSH27, vm.PUSH28, vm.PUSH29,
vm.PUSH30, vm.PUSH31, vm.PUSH32:
- pc.Add(pc, ethutil.Big1)
+ pc.Add(pc, common.Big1)
a := int64(op) - int64(vm.PUSH1) + 1
if int(pc.Int64()+a) > len(script) {
return
@@ -43,7 +43,7 @@ func Disassemble(script []byte) (asm []string) {
pc.Add(pc, big.NewInt(a-1))
}
- pc.Add(pc, ethutil.Big1)
+ pc.Add(pc, common.Big1)
}
return asm
diff --git a/core/block_processor.go b/core/block_processor.go
index f421c3539..f67d6d006 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -8,7 +8,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
@@ -24,8 +24,8 @@ type PendingBlockEvent struct {
var statelogger = logger.NewLogger("BLOCK")
type BlockProcessor struct {
- db ethutil.Database
- extraDb ethutil.Database
+ db common.Database
+ extraDb common.Database
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex sync.Mutex
// Canonical block chain
@@ -47,7 +47,7 @@ type BlockProcessor struct {
eventMux *event.TypeMux
}
-func NewBlockProcessor(db, extra ethutil.Database, pow pow.PoW, txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
+func NewBlockProcessor(db, extra common.Database, pow pow.PoW, txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
sm := &BlockProcessor{
db: db,
extraDb: extra,
@@ -217,7 +217,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// Commit state objects/accounts to a temporary trie (does not save)
// used to calculate the state root.
- state.Update(ethutil.Big0)
+ state.Update(common.Big0)
if !bytes.Equal(header.Root, state.Root()) {
err = fmt.Errorf("invalid merkle root. received=%x got=%x", header.Root, state.Root())
return
@@ -352,7 +352,7 @@ func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err erro
return state.Logs(), nil
}
-func putTx(db ethutil.Database, tx *types.Transaction) {
+func putTx(db common.Database, tx *types.Transaction) {
rlpEnc, err := rlp.EncodeToBytes(tx)
if err != nil {
statelogger.Infoln("Failed encoding tx", err)
diff --git a/core/chain_makers.go b/core/chain_makers.go
index f140b5c7e..59c297dbe 100644
--- a/core/chain_makers.go
+++ b/core/chain_makers.go
@@ -5,7 +5,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/state"
@@ -33,36 +33,36 @@ func NewBlockFromParent(addr []byte, parent *types.Block) *types.Block {
return newBlockFromParent(addr, parent)
}
-func MakeBlock(bman *BlockProcessor, parent *types.Block, i int, db ethutil.Database, seed int) *types.Block {
+func MakeBlock(bman *BlockProcessor, parent *types.Block, i int, db common.Database, seed int) *types.Block {
return makeBlock(bman, parent, i, db, seed)
}
-func MakeChain(bman *BlockProcessor, parent *types.Block, max int, db ethutil.Database, seed int) types.Blocks {
+func MakeChain(bman *BlockProcessor, parent *types.Block, max int, db common.Database, seed int) types.Blocks {
return makeChain(bman, parent, max, db, seed)
}
-func NewChainMan(block *types.Block, eventMux *event.TypeMux, db ethutil.Database) *ChainManager {
+func NewChainMan(block *types.Block, eventMux *event.TypeMux, db common.Database) *ChainManager {
return newChainManager(block, eventMux, db)
}
-func NewBlockProc(db ethutil.Database, txpool *TxPool, cman *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
+func NewBlockProc(db common.Database, txpool *TxPool, cman *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
return newBlockProcessor(db, txpool, cman, eventMux)
}
-func NewCanonical(n int, db ethutil.Database) (*BlockProcessor, error) {
+func NewCanonical(n int, db common.Database) (*BlockProcessor, error) {
return newCanonical(n, db)
}
// block time is fixed at 10 seconds
func newBlockFromParent(addr []byte, parent *types.Block) *types.Block {
- block := types.NewBlock(parent.Hash(), addr, parent.Root(), ethutil.BigPow(2, 32), 0, "")
+ block := types.NewBlock(parent.Hash(), addr, parent.Root(), common.BigPow(2, 32), 0, "")
block.SetUncles(nil)
block.SetTransactions(nil)
block.SetReceipts(nil)
header := block.Header()
header.Difficulty = CalcDifficulty(block.Header(), parent.Header())
- header.Number = new(big.Int).Add(parent.Header().Number, ethutil.Big1)
+ header.Number = new(big.Int).Add(parent.Header().Number, common.Big1)
header.Time = parent.Header().Time + 10
header.GasLimit = CalcGasLimit(parent, block)
@@ -73,22 +73,22 @@ func newBlockFromParent(addr []byte, parent *types.Block) *types.Block {
// Actually make a block by simulating what miner would do
// we seed chains by the first byte of the coinbase
-func makeBlock(bman *BlockProcessor, parent *types.Block, i int, db ethutil.Database, seed int) *types.Block {
- addr := ethutil.LeftPadBytes([]byte{byte(i)}, 20)
+func makeBlock(bman *BlockProcessor, parent *types.Block, i int, db common.Database, seed int) *types.Block {
+ addr := common.LeftPadBytes([]byte{byte(i)}, 20)
addr[0] = byte(seed)
block := newBlockFromParent(addr, parent)
state := state.New(block.Root(), db)
cbase := state.GetOrNewStateObject(addr)
cbase.SetGasPool(CalcGasLimit(parent, block))
cbase.AddBalance(BlockReward)
- state.Update(ethutil.Big0)
+ state.Update(common.Big0)
block.SetRoot(state.Root())
return block
}
// Make a chain with real blocks
// Runs ProcessWithParent to get proper state roots
-func makeChain(bman *BlockProcessor, parent *types.Block, max int, db ethutil.Database, seed int) types.Blocks {
+func makeChain(bman *BlockProcessor, parent *types.Block, max int, db common.Database, seed int) types.Blocks {
bman.bc.currentBlock = parent
blocks := make(types.Blocks, max)
for i := 0; i < max; i++ {
@@ -107,7 +107,7 @@ func makeChain(bman *BlockProcessor, parent *types.Block, max int, db ethutil.Da
// Create a new chain manager starting from given block
// Effectively a fork factory
-func newChainManager(block *types.Block, eventMux *event.TypeMux, db ethutil.Database) *ChainManager {
+func newChainManager(block *types.Block, eventMux *event.TypeMux, db common.Database) *ChainManager {
bc := &ChainManager{blockDb: db, stateDb: db, genesisBlock: GenesisBlock(db), eventMux: eventMux}
if block == nil {
bc.Reset()
@@ -119,14 +119,14 @@ func newChainManager(block *types.Block, eventMux *event.TypeMux, db ethutil.Dat
}
// block processor with fake pow
-func newBlockProcessor(db ethutil.Database, txpool *TxPool, cman *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
+func newBlockProcessor(db common.Database, txpool *TxPool, cman *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
bman := NewBlockProcessor(db, db, FakePow{}, txpool, newChainManager(nil, eventMux, db), eventMux)
return bman
}
// Make a new, deterministic canonical chain by running InsertChain
// on result of makeChain
-func newCanonical(n int, db ethutil.Database) (*BlockProcessor, error) {
+func newCanonical(n int, db common.Database) (*BlockProcessor, error) {
eventMux := &event.TypeMux{}
txpool := NewTxPool(eventMux)
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 0b7dcf293..ff91b0427 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -7,7 +7,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/rlp"
@@ -60,7 +60,7 @@ func CalculateTD(block, parent *types.Block) *big.Int {
func CalcGasLimit(parent, block *types.Block) *big.Int {
if block.Number().Cmp(big.NewInt(0)) == 0 {
- return ethutil.BigPow(10, 6)
+ return common.BigPow(10, 6)
}
// ((1024-1) * parent.gasLimit + (gasUsed * 6 / 5)) / 1024
@@ -71,13 +71,13 @@ func CalcGasLimit(parent, block *types.Block) *big.Int {
result := new(big.Int).Add(previous, curInt)
result.Div(result, big.NewInt(1024))
- return ethutil.BigMax(GenesisGasLimit, result)
+ return common.BigMax(GenesisGasLimit, result)
}
type ChainManager struct {
//eth EthManager
- blockDb ethutil.Database
- stateDb ethutil.Database
+ blockDb common.Database
+ stateDb common.Database
processor types.BlockProcessor
eventMux *event.TypeMux
genesisBlock *types.Block
@@ -94,7 +94,7 @@ type ChainManager struct {
quit chan struct{}
}
-func NewChainManager(blockDb, stateDb ethutil.Database, mux *event.TypeMux) *ChainManager {
+func NewChainManager(blockDb, stateDb common.Database, mux *event.TypeMux) *ChainManager {
bc := &ChainManager{blockDb: blockDb, stateDb: stateDb, genesisBlock: GenesisBlock(stateDb), eventMux: mux, quit: make(chan struct{})}
bc.setLastBlock()
bc.transState = bc.State().Copy()
@@ -173,7 +173,7 @@ func (bc *ChainManager) setLastBlock() {
bc.lastBlockHash = block.Hash()
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
- bc.td = ethutil.BigD(bc.blockDb.LastKnownTD())
+ bc.td = common.BigD(bc.blockDb.LastKnownTD())
} else {
bc.Reset()
}
@@ -198,7 +198,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block {
parentHash,
coinbase,
root,
- ethutil.BigPow(2, 32),
+ common.BigPow(2, 32),
0,
"")
block.SetUncles(nil)
@@ -209,7 +209,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block {
if parent != nil {
header := block.Header()
header.Difficulty = CalcDifficulty(block.Header(), parent.Header())
- header.Number = new(big.Int).Add(parent.Header().Number, ethutil.Big1)
+ header.Number = new(big.Int).Add(parent.Header().Number, common.Big1)
header.GasLimit = CalcGasLimit(parent, block)
}
@@ -230,7 +230,7 @@ func (bc *ChainManager) Reset() {
bc.insert(bc.genesisBlock)
bc.currentBlock = bc.genesisBlock
- bc.setTotalDifficulty(ethutil.Big("0"))
+ bc.setTotalDifficulty(common.Big("0"))
}
func (bc *ChainManager) removeBlock(block *types.Block) {
@@ -263,11 +263,11 @@ func (self *ChainManager) Export() []byte {
blocks[block.NumberU64()] = block
}
- return ethutil.Encode(blocks)
+ return common.Encode(blocks)
}
func (bc *ChainManager) insert(block *types.Block) {
- //encodedBlock := ethutil.Encode(block)
+ //encodedBlock := common.Encode(block)
bc.blockDb.Put([]byte("LastBlock"), block.Hash())
bc.currentBlock = block
bc.lastBlockHash = block.Hash()
@@ -277,7 +277,7 @@ func (bc *ChainManager) insert(block *types.Block) {
}
func (bc *ChainManager) write(block *types.Block) {
- encodedBlock := ethutil.Encode(block.RlpDataForStorage())
+ encodedBlock := common.Encode(block.RlpDataForStorage())
key := append(blockHashPre, block.Hash()...)
bc.blockDb.Put(key, encodedBlock)
@@ -309,7 +309,7 @@ func (self *ChainManager) GetBlockHashesFromHash(hash []byte, max uint64) (chain
}
chain = append(chain, block.Hash())
- if block.Header().Number.Cmp(ethutil.Big0) <= 0 {
+ if block.Header().Number.Cmp(common.Big0) <= 0 {
break
}
}
@@ -434,7 +434,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
// Compare the TD of the last known block in the canonical chain to make sure it's greater.
// At this point it's possible that a different chain (fork) becomes the new canonical chain.
if td.Cmp(self.td) > 0 {
- if block.Header().Number.Cmp(new(big.Int).Add(cblock.Header().Number, ethutil.Big1)) < 0 {
+ if block.Header().Number.Cmp(new(big.Int).Add(cblock.Header().Number, common.Big1)) < 0 {
chainlogger.Infof("Split detected. New head #%v (%x) TD=%v, was #%v (%x) TD=%v\n", block.Header().Number, block.Hash()[:4], td, cblock.Header().Number, cblock.Hash()[:4], self.td)
queue[i] = ChainSplitEvent{block}
@@ -446,10 +446,10 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
/* XXX crashes
jsonlogger.LogJson(&logger.EthChainNewHead{
- BlockHash: ethutil.Bytes2Hex(block.Hash()),
+ BlockHash: common.Bytes2Hex(block.Hash()),
BlockNumber: block.Number(),
- ChainHeadHash: ethutil.Bytes2Hex(cblock.Hash()),
- BlockPrevHash: ethutil.Bytes2Hex(block.ParentHash()),
+ ChainHeadHash: common.Bytes2Hex(cblock.Hash()),
+ BlockPrevHash: common.Bytes2Hex(block.ParentHash()),
})
*/
diff --git a/core/genesis.go b/core/genesis.go
index 9c82a28c8..bfd51f196 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
)
@@ -19,21 +19,21 @@ import (
var ZeroHash256 = make([]byte, 32)
var ZeroHash160 = make([]byte, 20)
var ZeroHash512 = make([]byte, 64)
-var EmptyShaList = crypto.Sha3(ethutil.Encode([]interface{}{}))
-var EmptyListRoot = crypto.Sha3(ethutil.Encode(""))
+var EmptyShaList = crypto.Sha3(common.Encode([]interface{}{}))
+var EmptyListRoot = crypto.Sha3(common.Encode(""))
var GenesisDiff = big.NewInt(131072)
var GenesisGasLimit = big.NewInt(3141592)
-func GenesisBlock(db ethutil.Database) *types.Block {
+func GenesisBlock(db common.Database) *types.Block {
genesis := types.NewBlock(ZeroHash256, ZeroHash160, nil, GenesisDiff, 42, "")
- genesis.Header().Number = ethutil.Big0
+ genesis.Header().Number = common.Big0
genesis.Header().GasLimit = GenesisGasLimit
- genesis.Header().GasUsed = ethutil.Big0
+ genesis.Header().GasUsed = common.Big0
genesis.Header().Time = 0
genesis.Header().MixDigest = make([]byte, 32)
- genesis.Td = ethutil.Big0
+ genesis.Td = common.Big0
genesis.SetUncles([]*types.Header{})
genesis.SetTransactions(types.Transactions{})
@@ -48,9 +48,9 @@ func GenesisBlock(db ethutil.Database) *types.Block {
statedb := state.New(genesis.Root(), db)
for addr, account := range accounts {
- codedAddr := ethutil.Hex2Bytes(addr)
+ codedAddr := common.Hex2Bytes(addr)
accountState := statedb.GetAccount(codedAddr)
- accountState.SetBalance(ethutil.Big(account.Balance))
+ accountState.SetBalance(common.Big(account.Balance))
statedb.UpdateStateObject(accountState)
}
statedb.Sync()
diff --git a/core/helper_test.go b/core/helper_test.go
index b7f05db64..1e0ed178b 100644
--- a/core/helper_test.go
+++ b/core/helper_test.go
@@ -7,7 +7,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
// "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
)
@@ -16,7 +16,7 @@ type TestManager struct {
// stateManager *StateManager
eventMux *event.TypeMux
- db ethutil.Database
+ db common.Database
txPool *TxPool
blockChain *ChainManager
Blocks []*types.Block
@@ -58,7 +58,7 @@ func (tm *TestManager) EventMux() *event.TypeMux {
// return nil
// }
-func (tm *TestManager) Db() ethutil.Database {
+func (tm *TestManager) Db() common.Database {
return tm.db
}
diff --git a/core/manager.go b/core/manager.go
index c4052cc05..9b5407a9e 100644
--- a/core/manager.go
+++ b/core/manager.go
@@ -1,7 +1,7 @@
package core
import (
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/p2p"
)
@@ -13,7 +13,7 @@ type Backend interface {
PeerCount() int
IsListening() bool
Peers() []*p2p.Peer
- BlockDb() ethutil.Database
- StateDb() ethutil.Database
+ BlockDb() common.Database
+ StateDb() common.Database
EventMux() *event.TypeMux
}
diff --git a/core/state_transition.go b/core/state_transition.go
index f49aed874..279abee62 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -5,7 +5,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
)
@@ -58,7 +58,7 @@ type Message interface {
func AddressFromMessage(msg Message) []byte {
// Generate a new address
- return crypto.Sha3(ethutil.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:]
+ return crypto.Sha3(common.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:]
}
func MessageCreatesContract(msg Message) bool {
@@ -226,9 +226,9 @@ func (self *StateTransition) refundGas() {
remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice())
sender.AddBalance(remaining)
- uhalf := new(big.Int).Div(self.gasUsed(), ethutil.Big2)
+ uhalf := new(big.Int).Div(self.gasUsed(), common.Big2)
for addr, ref := range self.state.Refunds() {
- refund := ethutil.BigMin(uhalf, ref)
+ refund := common.BigMin(uhalf, ref)
self.gas.Add(self.gas, refund)
self.state.AddBalance([]byte(addr), refund.Mul(refund, self.msg.GasPrice()))
}
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index bd377f679..515cc2040 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -6,7 +6,7 @@ import (
"sync"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
)
@@ -113,13 +113,13 @@ func (self *TxPool) add(tx *types.Transaction) error {
var to string
if len(tx.To()) > 0 {
- to = ethutil.Bytes2Hex(tx.To()[:4])
+ to = common.Bytes2Hex(tx.To()[:4])
} else {
to = "[NEW_CONTRACT]"
}
var from string
if len(tx.From()) > 0 {
- from = ethutil.Bytes2Hex(tx.From()[:4])
+ from = common.Bytes2Hex(tx.From()[:4])
} else {
return errors.New(fmt.Sprintf("FROM ADDRESS MUST BE POSITIVE (was %v)", tx.From()))
}
diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go
index b2d981f01..418cb0415 100644
--- a/core/transaction_pool_test.go
+++ b/core/transaction_pool_test.go
@@ -7,13 +7,13 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/state"
)
// State query interface
-type stateQuery struct{ db ethutil.Database }
+type stateQuery struct{ db common.Database }
func SQ() stateQuery {
db, _ := ethdb.NewMemDatabase()
@@ -25,7 +25,7 @@ func (self stateQuery) GetAccount(addr []byte) *state.StateObject {
}
func transaction() *types.Transaction {
- return types.NewTransactionMessage(make([]byte, 20), ethutil.Big0, ethutil.Big0, ethutil.Big0, nil)
+ return types.NewTransactionMessage(make([]byte, 20), common.Big0, common.Big0, common.Big0, nil)
}
func setup() (*TxPool, *ecdsa.PrivateKey) {
diff --git a/core/types/block.go b/core/types/block.go
index ba6ef6014..2d65cdca6 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -9,7 +9,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -74,11 +74,11 @@ func (self *Header) RlpData() interface{} {
}
func (self *Header) Hash() []byte {
- return crypto.Sha3(ethutil.Encode(self.rlpData(true)))
+ return crypto.Sha3(common.Encode(self.rlpData(true)))
}
func (self *Header) HashNoNonce() []byte {
- return crypto.Sha3(ethutil.Encode(self.rlpData(false)))
+ return crypto.Sha3(common.Encode(self.rlpData(false)))
}
type Block struct {
@@ -148,7 +148,7 @@ func (self *Block) Uncles() []*Header {
func (self *Block) SetUncles(uncleHeaders []*Header) {
self.uncles = uncleHeaders
- self.header.UncleHash = crypto.Sha3(ethutil.Encode(uncleHeaders))
+ self.header.UncleHash = crypto.Sha3(common.Encode(uncleHeaders))
}
func (self *Block) Transactions() Transactions {
@@ -213,7 +213,7 @@ func (self *Block) GasLimit() *big.Int { return self.header.GasLimit }
func (self *Block) GasUsed() *big.Int { return self.header.GasUsed }
func (self *Block) Root() []byte { return self.header.Root }
func (self *Block) SetRoot(root []byte) { self.header.Root = root }
-func (self *Block) Size() ethutil.StorageSize { return ethutil.StorageSize(len(ethutil.Encode(self))) }
+func (self *Block) Size() common.StorageSize { return common.StorageSize(len(common.Encode(self))) }
func (self *Block) GetTransaction(i int) *Transaction {
if len(self.transactions) > i {
return self.transactions[i]
diff --git a/core/types/bloom9.go b/core/types/bloom9.go
index 578265a34..af76f226f 100644
--- a/core/types/bloom9.go
+++ b/core/types/bloom9.go
@@ -4,7 +4,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
)
@@ -14,7 +14,7 @@ func CreateBloom(receipts Receipts) []byte {
bin.Or(bin, LogsBloom(receipt.logs))
}
- return ethutil.LeftPadBytes(bin.Bytes(), 256)
+ return common.LeftPadBytes(bin.Bytes(), 256)
}
func LogsBloom(logs state.Logs) *big.Int {
@@ -28,7 +28,7 @@ func LogsBloom(logs state.Logs) *big.Int {
}
for _, b := range data {
- bin.Or(bin, ethutil.BigD(bloom9(crypto.Sha3(b)).Bytes()))
+ bin.Or(bin, common.BigD(bloom9(crypto.Sha3(b)).Bytes()))
}
}
@@ -48,7 +48,7 @@ func bloom9(b []byte) *big.Int {
}
func BloomLookup(bin, topic []byte) bool {
- bloom := ethutil.BigD(bin)
+ bloom := common.BigD(bin)
cmp := bloom9(crypto.Sha3(topic))
return bloom.And(bloom, cmp).Cmp(cmp) == 0
diff --git a/core/types/bloom9_test.go b/core/types/bloom9_test.go
index 74e00cac6..0841bb859 100644
--- a/core/types/bloom9_test.go
+++ b/core/types/bloom9_test.go
@@ -22,10 +22,10 @@ func TestBloom9(t *testing.T) {
func TestAddress(t *testing.T) {
block := &Block{}
- block.Coinbase = ethutil.Hex2Bytes("22341ae42d6dd7384bc8584e50419ea3ac75b83f")
+ block.Coinbase = common.Hex2Bytes("22341ae42d6dd7384bc8584e50419ea3ac75b83f")
fmt.Printf("%x\n", crypto.Sha3(block.Coinbase))
bin := CreateBloom(block)
- fmt.Printf("bin = %x\n", ethutil.LeftPadBytes(bin, 64))
+ fmt.Printf("bin = %x\n", common.LeftPadBytes(bin, 64))
}
*/
diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go
index b2c442210..593a31f1c 100644
--- a/core/types/derive_sha.go
+++ b/core/types/derive_sha.go
@@ -2,7 +2,7 @@ package types
import (
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/trie"
)
@@ -15,7 +15,7 @@ func DeriveSha(list DerivableList) []byte {
db, _ := ethdb.NewMemDatabase()
trie := trie.New(nil, db)
for i := 0; i < list.Len(); i++ {
- trie.Update(ethutil.Encode(i), list.GetRlp(i))
+ trie.Update(common.Encode(i), list.GetRlp(i))
}
return trie.Root()
diff --git a/core/types/receipt.go b/core/types/receipt.go
index 49e68e233..be14d0e0e 100644
--- a/core/types/receipt.go
+++ b/core/types/receipt.go
@@ -5,7 +5,7 @@ import (
"fmt"
"math/big"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/state"
)
@@ -17,10 +17,10 @@ type Receipt struct {
}
func NewReceipt(root []byte, cumalativeGasUsed *big.Int) *Receipt {
- return &Receipt{PostState: ethutil.CopyBytes(root), CumulativeGasUsed: new(big.Int).Set(cumalativeGasUsed)}
+ return &Receipt{PostState: common.CopyBytes(root), CumulativeGasUsed: new(big.Int).Set(cumalativeGasUsed)}
}
-func NewRecieptFromValue(val *ethutil.Value) *Receipt {
+func NewRecieptFromValue(val *common.Value) *Receipt {
r := &Receipt{}
r.RlpValueDecode(val)
@@ -31,7 +31,7 @@ func (self *Receipt) SetLogs(logs state.Logs) {
self.logs = logs
}
-func (self *Receipt) RlpValueDecode(decoder *ethutil.Value) {
+func (self *Receipt) RlpValueDecode(decoder *common.Value) {
self.PostState = decoder.Get(0).Bytes()
self.CumulativeGasUsed = decoder.Get(1).BigInt()
self.Bloom = decoder.Get(2).Bytes()
@@ -47,7 +47,7 @@ func (self *Receipt) RlpData() interface{} {
}
func (self *Receipt) RlpEncode() []byte {
- return ethutil.Encode(self.RlpData())
+ return common.Encode(self.RlpData())
}
func (self *Receipt) Cmp(other *Receipt) bool {
@@ -74,8 +74,8 @@ func (self Receipts) RlpData() interface{} {
}
func (self Receipts) RlpEncode() []byte {
- return ethutil.Encode(self.RlpData())
+ return common.Encode(self.RlpData())
}
func (self Receipts) Len() int { return len(self) }
-func (self Receipts) GetRlp(i int) []byte { return ethutil.Rlp(self[i]) }
+func (self Receipts) GetRlp(i int) []byte { return common.Rlp(self[i]) }
diff --git a/core/types/transaction.go b/core/types/transaction.go
index 88a718f93..dcd48af11 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
- "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -42,7 +42,7 @@ func NewTransactionFromBytes(data []byte) *Transaction {
return tx
}
-func NewTransactionFromAmount(val *ethutil.Value) *Transaction {
+func NewTransactionFromAmount(val *common.Value) *Transaction {
tx := &Transaction{}
tx.RlpValueDecode(val)
@@ -52,7 +52,7 @@ func NewTransactionFromAmount(val *ethutil.Value) *Transaction {
func (tx *Transaction) Hash() []byte {
data := []interface{}{tx.AccountNonce, tx.Price, tx.GasLimit, tx.Recipient, tx.Amount, tx.Payload}
- return crypto.Sha3(ethutil.Encode(data))
+ return crypto.Sha3(common.Encode(data))
}
func (self *Transaction) Data() []byte {
@@ -89,8 +89,8 @@ func (self *Transaction) To() []byte {
func (tx *Transaction) Curve() (v byte, r []byte, s []byte) {
v = byte(tx.V)
- r = ethutil.LeftPadBytes(tx.R, 32)
- s = ethutil.LeftPadBytes(tx.S, 32)
+ r = common.LeftPadBytes(tx.R, 32)
+ s = common.LeftPadBytes(tx.S, 32)
return
}
@@ -159,14 +159,14 @@ func (tx *Transaction) RlpData() interface{} {
}
func (tx *Transaction) RlpEncode() []byte {
- return ethutil.Encode(tx)
+ return common.Encode(tx)
}
func (tx *Transaction) RlpDecode(data []byte) {
rlp.Decode(bytes.NewReader(data), tx)
}
-func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
+func (tx *Transaction) RlpValueDecode(decoder *common.Value) {
tx.AccountNonce = decoder.Get(0).Uint()
tx.Price = decoder.Get(1).BigInt()
tx.GasLimit = decoder.Get(2).BigInt()
@@ -206,7 +206,7 @@ func (tx *Transaction) String() string {
tx.V,
tx.R,
tx.S,
- ethutil.Encode(tx),
+ common.Encode(tx),
)
}
@@ -225,7 +225,7 @@ func (self Transactions) RlpData() interface{} {
}
func (s Transactions) Len() int { return len(s) }
func (s Transactions) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
-func (s Transactions) GetRlp(i int) []byte { return ethutil.Rlp(s[i]) }
+func (s Transactions) GetRlp(i int) []byte { return common.Rlp(s[i]) }
type TxByNonce struct{ Transactions }