@@ -149,10 +149,7 @@ func (block *Block) Hash() ethutil.Bytes {
149149}
150150
151151func (block * Block ) HashNoNonce () []byte {
152- return ethcrypto .Sha3 (ethutil .Encode ([]interface {}{block .PrevHash ,
153- block .UncleSha , block .Coinbase , block .state .Trie .Root ,
154- block .ReceiptSha , block .Difficulty , block .Number , block .MinGasPrice ,
155- block .GasLimit , block .GasUsed , block .Time , block .Extra }))
152+ return ethcrypto .Sha3 (ethutil .Encode (block .miningHeader ()))
156153}
157154
158155func (block * Block ) State () * ethstate.State {
@@ -235,31 +232,18 @@ func (block *Block) rlpUncles() interface{} {
235232
236233func (block * Block ) SetUncles (uncles []* Block ) {
237234 block .Uncles = uncles
238-
239235 block .UncleSha = ethcrypto .Sha3 (ethutil .Encode (block .rlpUncles ()))
240236}
241237
242238func (self * Block ) SetReceipts (receipts Receipts ) {
243239 self .receipts = receipts
244- self .SetReceiptHash (receipts )
240+ self .ReceiptSha = DeriveSha (receipts )
241+ self .LogsBloom = CreateBloom (self )
245242}
246243
247244func (self * Block ) SetTransactions (txs Transactions ) {
248- self .setTransactions (txs )
249- self .SetTransactionHash (txs )
250- }
251-
252- func (block * Block ) setTransactions (txs Transactions ) {
253- block .transactions = txs
254- block .LogsBloom = CreateBloom (block )
255- }
256-
257- func (self * Block ) SetTransactionHash (transactions Transactions ) {
258- self .TxSha = DeriveSha (transactions )
259- }
260-
261- func (self * Block ) SetReceiptHash (receipts Receipts ) {
262- self .ReceiptSha = DeriveSha (receipts )
245+ self .transactions = txs
246+ self .TxSha = DeriveSha (txs )
263247}
264248
265249func (block * Block ) Value () * ethutil.Value {
@@ -285,10 +269,10 @@ func (block *Block) RlpValueDecode(decoder *ethutil.Value) {
285269 if decoder .Get (1 ).IsNil () == false { // Yes explicitness
286270 //receipts := decoder.Get(1)
287271 //block.receipts = make([]*Receipt, receipts.Len())
288- it := decoder .Get (1 ). NewIterator ( )
289- block .transactions = make (Transactions , it .Len ())
290- for it . Next () {
291- block .transactions [it . Idx () ] = NewTransactionFromValue (it . Value ( ))
272+ txs := decoder .Get (1 )
273+ block .transactions = make (Transactions , txs .Len ())
274+ for i := 0 ; i < txs . Len (); i ++ {
275+ block .transactions [i ] = NewTransactionFromValue (txs . Get ( i ))
292276 //receipt := NewRecieptFromValue(receipts.Get(i))
293277 //block.transactions[i] = receipt.Tx
294278 //block.receipts[i] = receipt
@@ -347,7 +331,7 @@ func (self *Block) Receipts() []*Receipt {
347331 return self .receipts
348332}
349333
350- func (block * Block ) header () []interface {} {
334+ func (block * Block ) miningHeader () []interface {} {
351335 return []interface {}{
352336 // Sha of the previous block
353337 block .PrevHash ,
@@ -377,11 +361,13 @@ func (block *Block) header() []interface{} {
377361 block .Time ,
378362 // Extra data
379363 block .Extra ,
380- // Block's Nonce for validation
381- block .Nonce ,
382364 }
383365}
384366
367+ func (block * Block ) header () []interface {} {
368+ return append (block .miningHeader (), block .Nonce )
369+ }
370+
385371func (block * Block ) String () string {
386372 return fmt .Sprintf (`
387373 BLOCK(%x): Size: %v
0 commit comments