core/types: fix receipt legacy decoding
This commit is contained in:
parent
dac7cbcf21
commit
1bc7f3f906
@ -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.
|
// Note some redundant fields(e.g. block number, tx hash etc) will be assembled later.
|
||||||
func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error {
|
func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error {
|
||||||
|
blob, err := s.Raw()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
var dec rlpStorageLog
|
var dec rlpStorageLog
|
||||||
err := s.Decode(&dec)
|
err = rlp.DecodeBytes(blob, &dec)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
*l = LogForStorage{
|
*l = LogForStorage{
|
||||||
Address: dec.Address,
|
Address: dec.Address,
|
||||||
@ -126,7 +130,7 @@ func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error {
|
|||||||
} else {
|
} else {
|
||||||
// Try to decode log with previous definition.
|
// Try to decode log with previous definition.
|
||||||
var dec LegacyRlpStorageLog
|
var dec LegacyRlpStorageLog
|
||||||
err = s.Decode(&dec)
|
err = rlp.DecodeBytes(blob, &dec)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
*l = LogForStorage{
|
*l = LogForStorage{
|
||||||
Address: dec.Address,
|
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
|
// DecodeRLP implements rlp.Decoder, and loads both consensus and implementation
|
||||||
// fields of a receipt from an RLP stream.
|
// fields of a receipt from an RLP stream.
|
||||||
func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error {
|
func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error {
|
||||||
|
blob, err := s.Raw()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
var dec receiptStorageRLP
|
var dec receiptStorageRLP
|
||||||
if err := s.Decode(&dec); err != nil {
|
if err := rlp.DecodeBytes(blob, &dec); err != nil {
|
||||||
var sdec LegacyReceiptStorageRLP
|
var sdec LegacyReceiptStorageRLP
|
||||||
if err := s.Decode(&sdec); err != nil {
|
if err := rlp.DecodeBytes(blob, &sdec); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dec.PostStateOrStatus = common.CopyBytes(sdec.PostStateOrStatus)
|
dec.PostStateOrStatus = common.CopyBytes(sdec.PostStateOrStatus)
|
||||||
|
Loading…
Reference in New Issue
Block a user