From ff8286eb3be21e3a3109d04b4e33d9c771ab251a Mon Sep 17 00:00:00 2001 From: Manas Nagaraj Date: Mon, 16 Oct 2023 21:24:47 +0530 Subject: [PATCH] core/rawdb: resolving code redundancy --- core/rawdb/accessors_chain.go | 13 ++----------- core/types/receipt.go | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 97401d283c..f8cd116ee8 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -681,25 +681,16 @@ func DeleteReceipts(db ethdb.KeyValueWriter, hash common.Hash, number uint64) { } } -// storedReceiptRLP is the storage encoding of a receipt. -// Re-definition in core/types/receipt.go. -// TODO: Re-use the existing definition. -type storedReceiptRLP struct { - PostStateOrStatus []byte - CumulativeGasUsed uint64 - Logs []*types.Log -} - // ReceiptLogs is a barebone version of ReceiptForStorage which only keeps // the list of logs. When decoding a stored receipt into this object we // avoid creating the bloom filter. type receiptLogs struct { - Logs []*types.Log + Logs []*types.Log } // DecodeRLP implements rlp.Decoder. func (r *receiptLogs) DecodeRLP(s *rlp.Stream) error { - var stored storedReceiptRLP + var stored types.StoredReceiptRLP if err := s.Decode(&stored); err != nil { return err } diff --git a/core/types/receipt.go b/core/types/receipt.go index 4f96fde59c..ebe42fa7c3 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -95,7 +95,7 @@ type receiptRLP struct { } // storedReceiptRLP is the storage encoding of a receipt. -type storedReceiptRLP struct { +type StoredReceiptRLP struct { PostStateOrStatus []byte CumulativeGasUsed uint64 Logs []*Log @@ -282,7 +282,7 @@ 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 { - var stored storedReceiptRLP + var stored StoredReceiptRLP if err := s.Decode(&stored); err != nil { return err }