core/types: fix receipt legacy decoding

This commit is contained in:
Péter Szilágyi 2019-02-28 14:15:52 +02:00
parent dac7cbcf21
commit 1bc7f3f906
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
2 changed files with 12 additions and 4 deletions

@ -115,8 +115,12 @@ func (l *LogForStorage) EncodeRLP(w io.Writer) error {
//
// Note some redundant fields(e.g. block number, tx hash etc) will be assembled later.
func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error {
blob, err := s.Raw()
if err != nil {
return err
}
var dec rlpStorageLog
err := s.Decode(&dec)
err = rlp.DecodeBytes(blob, &dec)
if err == nil {
*l = LogForStorage{
Address: dec.Address,
@ -126,7 +130,7 @@ func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error {
} else {
// Try to decode log with previous definition.
var dec LegacyRlpStorageLog
err = s.Decode(&dec)
err = rlp.DecodeBytes(blob, &dec)
if err == nil {
*l = LogForStorage{
Address: dec.Address,

@ -184,10 +184,14 @@ func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error {
// DecodeRLP implements rlp.Decoder, and loads both consensus and implementation
// fields of a receipt from an RLP stream.
func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error {
blob, err := s.Raw()
if err != nil {
return err
}
var dec receiptStorageRLP
if err := s.Decode(&dec); err != nil {
if err := rlp.DecodeBytes(blob, &dec); err != nil {
var sdec LegacyReceiptStorageRLP
if err := s.Decode(&sdec); err != nil {
if err := rlp.DecodeBytes(blob, &sdec); err != nil {
return err
}
dec.PostStateOrStatus = common.CopyBytes(sdec.PostStateOrStatus)