@@ -232,25 +232,26 @@ func (tx *minimalTx) EncodeRLP(w io.Writer) error {
232232// a view over a regular transactions slice, to RLP decode/encode the transactions all the minimal way
233233type extBlockTxs []* Transaction
234234
235- func (txs extBlockTxs ) DecodeRLP (s * rlp.Stream ) error {
235+ func (txs * extBlockTxs ) DecodeRLP (s * rlp.Stream ) error {
236236 // we need generics to do this nicely...
237237 var out []* minimalTx
238- for i , tx := range txs {
238+ for i , tx := range * txs {
239239 out [i ] = (* minimalTx )(tx )
240240 }
241241 if err := s .Decode (& out ); err != nil {
242242 return fmt .Errorf ("failed to decode list of minimal txs: %v" , err )
243243 }
244- txs = make ([]* Transaction , len (out ))
244+ rawtxs : = make ([]* Transaction , len (out ))
245245 for i , tx := range out {
246- txs [i ] = (* Transaction )(tx )
246+ rawtxs [i ] = (* Transaction )(tx )
247247 }
248+ * txs = rawtxs
248249 return nil
249250}
250251
251- func (txs extBlockTxs ) EncodeRLP (w io.Writer ) error {
252- out := make ([]* minimalTx , len (txs ))
253- for i , tx := range txs {
252+ func (txs * extBlockTxs ) EncodeRLP (w io.Writer ) error {
253+ out := make ([]* minimalTx , len (* txs ))
254+ for i , tx := range * txs {
254255 out [i ] = (* minimalTx )(tx )
255256 }
256257 return rlp .Encode (w , & out )
@@ -259,7 +260,7 @@ func (txs extBlockTxs) EncodeRLP(w io.Writer) error {
259260// "external" block encoding. used for eth protocol, etc.
260261type extblock struct {
261262 Header * Header
262- Txs extBlockTxs
263+ Txs * extBlockTxs
263264 Uncles []* Header
264265}
265266
@@ -331,17 +332,17 @@ func CopyHeader(h *Header) *Header {
331332
332333// DecodeRLP decodes the Ethereum
333334func (b * Block ) DecodeRLP (s * rlp.Stream ) error {
334- var eb extblock
335+ eb := extblock { Txs : new ( extBlockTxs )}
335336 _ , size , _ := s .Kind ()
336337 if err := s .Decode (& eb ); err != nil {
337338 return err
338339 }
339- for i , tx := range eb .Txs {
340+ for i , tx := range * eb .Txs {
340341 if tx .wrapData != nil {
341342 return fmt .Errorf ("transactions in blocks must not contain wrap-data, tx %d is bad" , i )
342343 }
343344 }
344- b .header , b .uncles , b .transactions = eb .Header , eb .Uncles , []* Transaction (eb .Txs )
345+ b .header , b .uncles , b .transactions = eb .Header , eb .Uncles , []* Transaction (* eb .Txs )
345346 b .size .Store (common .StorageSize (rlp .ListSize (size )))
346347 return nil
347348}
@@ -350,7 +351,7 @@ func (b *Block) DecodeRLP(s *rlp.Stream) error {
350351func (b * Block ) EncodeRLP (w io.Writer ) error {
351352 return rlp .Encode (w , extblock {
352353 Header : b .header ,
353- Txs : (extBlockTxs )(b .transactions ),
354+ Txs : (* extBlockTxs )(& b .transactions ),
354355 Uncles : b .uncles ,
355356 })
356357}
0 commit comments