aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-04 16:38:18 +0800
committerobscuren <geffobscura@gmail.com>2014-08-04 16:38:18 +0800
commit3debeb7236d2c8474fa9049cc91dc26bf1040b3f (patch)
tree928b5ff8486ea485a3efae8cc69adaf54af9c87e /ethchain
parent2e7cf835222274a311302c33498cf83bb2593b7a (diff)
downloaddexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar.gz
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar.zst
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.zip
ethtrie.NewTrie => ethtrie.New
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/block.go24
-rw-r--r--ethchain/block_chain.go10
-rw-r--r--ethchain/state_transition.go2
3 files changed, 10 insertions, 26 deletions
diff --git a/ethchain/block.go b/ethchain/block.go
index ac56f58c3..e4486f8e4 100644
--- a/ethchain/block.go
+++ b/ethchain/block.go
@@ -100,7 +100,7 @@ func CreateBlock(root interface{},
}
block.SetUncles([]*Block{})
- block.state = ethstate.NewState(ethtrie.NewTrie(ethutil.Config.Db, root))
+ block.state = ethstate.NewState(ethtrie.New(ethutil.Config.Db, root))
return block
}
@@ -220,26 +220,10 @@ func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction) {
func (block *Block) setTransactions(txs []*Transaction) {
block.transactions = txs
-
- /*
- trie := ethtrie.NewTrie(ethutil.Config.Db, "")
- for i, tx := range txs {
- trie.Update(strconv.Itoa(i), string(tx.RlpEncode()))
- }
-
- switch trie.Root.(type) {
- case string:
- block.TxSha = []byte(trie.Root.(string))
- case []byte:
- block.TxSha = trie.Root.([]byte)
- default:
- panic(fmt.Sprintf("invalid root type %T", trie.Root))
- }
- */
}
func CreateTxSha(receipts Receipts) (sha []byte) {
- trie := ethtrie.NewTrie(ethutil.Config.Db, "")
+ trie := ethtrie.New(ethutil.Config.Db, "")
for i, receipt := range receipts {
trie.Update(string(ethutil.NewValue(i).Encode()), string(ethutil.NewValue(receipt.RlpData()).Encode()))
}
@@ -281,7 +265,7 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) {
block.PrevHash = header.Get(0).Bytes()
block.UncleSha = header.Get(1).Bytes()
block.Coinbase = header.Get(2).Bytes()
- block.state = ethstate.NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val))
+ block.state = ethstate.NewState(ethtrie.New(ethutil.Config.Db, header.Get(3).Val))
block.TxSha = header.Get(4).Bytes()
block.Difficulty = header.Get(5).BigInt()
block.Number = header.Get(6).BigInt()
@@ -323,7 +307,7 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
block.PrevHash = header.Get(0).Bytes()
block.UncleSha = header.Get(1).Bytes()
block.Coinbase = header.Get(2).Bytes()
- block.state = ethstate.NewState(ethtrie.NewTrie(ethutil.Config.Db, header.Get(3).Val))
+ block.state = ethstate.NewState(ethtrie.New(ethutil.Config.Db, header.Get(3).Val))
block.TxSha = header.Get(4).Bytes()
block.Difficulty = header.Get(5).BigInt()
block.Number = header.Get(6).BigInt()
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go
index 250903798..736fe52c7 100644
--- a/ethchain/block_chain.go
+++ b/ethchain/block_chain.go
@@ -132,7 +132,7 @@ func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte
// Start with the newest block we got, all the way back to the common block we both know
for _, block := range blocks {
if bytes.Compare(block.Hash(), commonBlockHash) == 0 {
- chainlogger.Infoln("[CHAIN] We have found the common parent block, breaking")
+ chainlogger.Infoln("We have found the common parent block, breaking")
break
}
chainDifficulty.Add(chainDifficulty, bc.CalculateBlockTD(block))
@@ -145,13 +145,13 @@ func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte
for i := 0; block != nil; block = bc.GetBlock(block.PrevHash) {
i++
if bytes.Compare(block.Hash(), commonBlockHash) == 0 {
- chainlogger.Infoln("We have found the common parent block, breaking")
+ chainlogger.Infoln("Found the common parent block")
break
}
anOtherBlock := bc.GetBlock(block.PrevHash)
if anOtherBlock == nil {
// We do not want to count the genesis block for difficulty since that's not being sent
- chainlogger.Infoln("At genesis block, breaking")
+ chainlogger.Infoln("Found genesis block. Stop")
break
}
curChainDifficulty.Add(curChainDifficulty, bc.CalculateBlockTD(block))
@@ -159,11 +159,11 @@ func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte
chainlogger.Infoln("Current chain difficulty:", curChainDifficulty)
if chainDifficulty.Cmp(curChainDifficulty) == 1 {
- chainlogger.Infof("The incoming Chain beat our asses, resetting to block: %x", commonBlockHash)
+ chainlogger.Infof("Resetting to block %x. Changing chain.")
bc.ResetTillBlockHash(commonBlockHash)
return false
} else {
- chainlogger.Infoln("Our chain showed the incoming chain who is boss. Ignoring.")
+ chainlogger.Infoln("Current chain is longest chain. Ignoring incoming chain.")
return true
}
}
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go
index 02a8e0e82..8f1561c00 100644
--- a/ethchain/state_transition.go
+++ b/ethchain/state_transition.go
@@ -278,7 +278,7 @@ func MakeContract(tx *Transaction, state *ethstate.State) *ethstate.StateObject
contract := state.NewStateObject(addr)
contract.InitCode = tx.Data
- contract.State = ethstate.NewState(ethtrie.NewTrie(ethutil.Config.Db, ""))
+ contract.State = ethstate.NewState(ethtrie.New(ethutil.Config.Db, ""))
return contract
}