|
|
@ -56,8 +56,6 @@ type Block struct { |
|
|
|
// List of transactions and/or contracts
|
|
|
|
// List of transactions and/or contracts
|
|
|
|
transactions []*Transaction |
|
|
|
transactions []*Transaction |
|
|
|
TxSha []byte |
|
|
|
TxSha []byte |
|
|
|
|
|
|
|
|
|
|
|
contractStates map[string]*ethutil.Trie |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// New block takes a raw encoded string
|
|
|
|
// New block takes a raw encoded string
|
|
|
@ -91,28 +89,23 @@ func CreateBlock(root interface{}, |
|
|
|
|
|
|
|
|
|
|
|
block := &Block{ |
|
|
|
block := &Block{ |
|
|
|
// Slice of transactions to include in this block
|
|
|
|
// Slice of transactions to include in this block
|
|
|
|
transactions: txes, |
|
|
|
transactions: txes, |
|
|
|
PrevHash: prevHash, |
|
|
|
PrevHash: prevHash, |
|
|
|
Coinbase: base, |
|
|
|
Coinbase: base, |
|
|
|
Difficulty: Difficulty, |
|
|
|
Difficulty: Difficulty, |
|
|
|
Nonce: Nonce, |
|
|
|
Nonce: Nonce, |
|
|
|
Time: time.Now().Unix(), |
|
|
|
Time: time.Now().Unix(), |
|
|
|
Extra: extra, |
|
|
|
Extra: extra, |
|
|
|
UncleSha: EmptyShaList, |
|
|
|
UncleSha: EmptyShaList, |
|
|
|
GasUsed: new(big.Int), |
|
|
|
GasUsed: new(big.Int), |
|
|
|
MinGasPrice: new(big.Int), |
|
|
|
MinGasPrice: new(big.Int), |
|
|
|
GasLimit: new(big.Int), |
|
|
|
GasLimit: new(big.Int), |
|
|
|
contractStates: make(map[string]*ethutil.Trie), |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
block.SetTransactions(txes) |
|
|
|
block.SetTransactions(txes) |
|
|
|
block.SetUncles([]*Block{}) |
|
|
|
block.SetUncles([]*Block{}) |
|
|
|
|
|
|
|
|
|
|
|
block.state = NewState(ethutil.NewTrie(ethutil.Config.Db, root)) |
|
|
|
block.state = NewState(ethutil.NewTrie(ethutil.Config.Db, root)) |
|
|
|
|
|
|
|
|
|
|
|
for _, tx := range txes { |
|
|
|
|
|
|
|
block.MakeContract(tx) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return block |
|
|
|
return block |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -178,13 +171,6 @@ func (block *Block) Undo() { |
|
|
|
block.state.Reset() |
|
|
|
block.state.Reset() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (block *Block) MakeContract(tx *Transaction) { |
|
|
|
|
|
|
|
contract := MakeContract(tx, block.state) |
|
|
|
|
|
|
|
if contract != nil { |
|
|
|
|
|
|
|
block.state.states[string(tx.Hash()[12:])] = contract.state |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////// Block Encoding
|
|
|
|
/////// Block Encoding
|
|
|
|
func (block *Block) rlpTxs() interface{} { |
|
|
|
func (block *Block) rlpTxs() interface{} { |
|
|
|
// Marshal the transactions of this block
|
|
|
|
// Marshal the transactions of this block
|
|
|
@ -265,7 +251,6 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) { |
|
|
|
block.Time = int64(header.Get(10).BigInt().Uint64()) |
|
|
|
block.Time = int64(header.Get(10).BigInt().Uint64()) |
|
|
|
block.Extra = header.Get(11).Str() |
|
|
|
block.Extra = header.Get(11).Str() |
|
|
|
block.Nonce = header.Get(12).Bytes() |
|
|
|
block.Nonce = header.Get(12).Bytes() |
|
|
|
block.contractStates = make(map[string]*ethutil.Trie) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tx list might be empty if this is an uncle. Uncles only have their
|
|
|
|
// Tx list might be empty if this is an uncle. Uncles only have their
|
|
|
|
// header set.
|
|
|
|
// header set.
|
|
|
|