aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-20 21:02:46 +0800
committerobscuren <geffobscura@gmail.com>2014-05-20 21:02:46 +0800
commit2bd377a3de54652923558b63cc8756531269e36e (patch)
tree070e258a4e82948c6dad0c2ce7468dd20f932b88 /ethchain
parent7d3e99a2abcef6011714a7e6e515aa8e2bc738cc (diff)
downloadgo-tangerine-2bd377a3de54652923558b63cc8756531269e36e.tar
go-tangerine-2bd377a3de54652923558b63cc8756531269e36e.tar.gz
go-tangerine-2bd377a3de54652923558b63cc8756531269e36e.tar.bz2
go-tangerine-2bd377a3de54652923558b63cc8756531269e36e.tar.lz
go-tangerine-2bd377a3de54652923558b63cc8756531269e36e.tar.xz
go-tangerine-2bd377a3de54652923558b63cc8756531269e36e.tar.zst
go-tangerine-2bd377a3de54652923558b63cc8756531269e36e.zip
Changed transaction hash for poc 5
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/block.go76
-rw-r--r--ethchain/block_chain.go16
-rw-r--r--ethchain/genesis.go3
3 files changed, 57 insertions, 38 deletions
diff --git a/ethchain/block.go b/ethchain/block.go
index beb2bc14c..c6c2c1226 100644
--- a/ethchain/block.go
+++ b/ethchain/block.go
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethutil"
"math/big"
+ "strconv"
"time"
)
@@ -214,7 +215,12 @@ func (block *Block) SetUncles(uncles []*Block) {
func (block *Block) SetTransactions(txs []*Transaction) {
block.transactions = txs
- block.TxSha = ethutil.Sha3Bin(ethutil.Encode(block.rlpTxs()))
+ trie := ethutil.NewTrie(ethutil.Config.Db, "")
+ for i, tx := range txs {
+ trie.Update(strconv.Itoa(i), string(tx.RlpEncode()))
+ }
+
+ block.TxSha = trie.Root.([]byte)
}
func (block *Block) Value() *ethutil.Value {
@@ -293,45 +299,10 @@ func NewUncleBlockFromValue(header *ethutil.Value) *Block {
return block
}
-func (block *Block) String() string {
- //return fmt.Sprintf("Block(%x):\nPrevHash:%x\nUncleSha:%x\nCoinbase:%x\nRoot:%x\nTxSha:%x\nDiff:%v\nNonce:%x\nTxs:%d\n", block.Hash(), block.PrevHash, block.UncleSha, block.Coinbase, block.state.trie.Root, block.TxSha, block.Difficulty, block.Time, block.Nonce, len(block.transactions))
- return fmt.Sprintf(`
- Block(%x):
- PrevHash: %x
- UncleSha: %x
- Coinbase: %x
- Root: %x
- TxSha: %x
- Difficulty: %v
- Number: %v
- MinGas: %v
- MaxLimit: %v
- GasUsed: %v
- Time: %v
- Extra: %v
- Nonce: %x
-`,
- block.Hash(),
- block.PrevHash,
- block.UncleSha,
- block.Coinbase,
- block.state.trie.Root,
- block.TxSha,
- block.Difficulty,
- block.Number,
- block.MinGasPrice,
- block.GasLimit,
- block.GasUsed,
- block.Time,
- block.Extra,
- block.Nonce)
-}
-
func (block *Block) GetRoot() interface{} {
return block.state.trie.Root
}
-//////////// UNEXPORTED /////////////////
func (block *Block) header() []interface{} {
return []interface{}{
// Sha of the previous block
@@ -362,3 +333,36 @@ func (block *Block) header() []interface{} {
block.Nonce,
}
}
+
+func (block *Block) String() string {
+ return fmt.Sprintf(`
+ BLOCK(%x):
+ PrevHash: %x
+ UncleSha: %x
+ Coinbase: %x
+ Root: %x
+ TxSha: %x
+ Difficulty: %v
+ Number: %v
+ MinGas: %v
+ MaxLimit: %v
+ GasUsed: %v
+ Time: %v
+ Extra: %v
+ Nonce: %x
+`,
+ block.Hash(),
+ block.PrevHash,
+ block.UncleSha,
+ block.Coinbase,
+ block.state.trie.Root,
+ block.TxSha,
+ block.Difficulty,
+ block.Number,
+ block.MinGasPrice,
+ block.GasLimit,
+ block.GasUsed,
+ block.Time,
+ block.Extra,
+ block.Nonce)
+}
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go
index eb25bd3f4..2865336fb 100644
--- a/ethchain/block_chain.go
+++ b/ethchain/block_chain.go
@@ -70,6 +70,22 @@ func (bc *BlockChain) NewBlock(coinbase []byte, txs []*Transaction) *Block {
diff.Mul(diff, mul)
diff.Add(diff, bc.CurrentBlock.Difficulty)
block.Difficulty = diff
+
+ block.Number = new(big.Int).Add(bc.CurrentBlock.Number, ethutil.Big1)
+
+ // max(10000, (parent gas limit * (1024 - 1) + (parent gas used * 6 / 5)) / 1024)
+ base := new(big.Int)
+ base2 := new(big.Int)
+ parentGL := bc.CurrentBlock.GasLimit
+ parentUsed := bc.CurrentBlock.GasUsed
+
+ base.Mul(parentGL, big.NewInt(1024-1))
+ base2.Mul(parentUsed, big.NewInt(6))
+ base2.Div(base2, big.NewInt(5))
+ base.Add(base, base2)
+ base.Div(base, big.NewInt(1024))
+
+ block.GasLimit = ethutil.BigMax(big.NewInt(10000), base)
}
return block
diff --git a/ethchain/genesis.go b/ethchain/genesis.go
index 7e145ef53..b8f9f865a 100644
--- a/ethchain/genesis.go
+++ b/ethchain/genesis.go
@@ -22,9 +22,8 @@ var GenesisHeader = []interface{}{
ZeroHash160,
// Root state
"",
- //EmptyShaList,
+ // tx sha
ZeroHash256,
- //ethutil.Sha3Bin(ethutil.Encode(ZeroHash256)),
// Difficulty
ethutil.BigPow(2, 22),
// Number