From 99b00d4bbc6bad10beec2072277f9505757786ec Mon Sep 17 00:00:00 2001 From: gop Date: Fri, 22 Mar 2024 19:43:59 -0500 Subject: [PATCH] Remove the encode and decode rlp for block --- core/headerchain.go | 17 ----------------- core/types/block.go | 32 -------------------------------- 2 files changed, 49 deletions(-) diff --git a/core/headerchain.go b/core/headerchain.go index 4829b0a4b9..ca1794e978 100644 --- a/core/headerchain.go +++ b/core/headerchain.go @@ -855,23 +855,6 @@ func (hc *HeaderChain) Export(w io.Writer) error { // ExportN writes a subset of the active chain to the given writer. func (hc *HeaderChain) ExportN(w io.Writer, first uint64, last uint64) error { - hc.headermu.RLock() - defer hc.headermu.RUnlock() - - if first > last { - return fmt.Errorf("export failed: first (%d) is greater than last (%d)", first, last) - } - hc.logger.WithField("count", last-first+1).Info("Exporting batch of blocks") - - for nr := first; nr <= last; nr++ { - block := hc.GetBlockByNumber(nr) - if block == nil { - return fmt.Errorf("export failed on #%d: not found", nr) - } - if err := block.EncodeRLP(w); err != nil { - return err - } - } return nil } diff --git a/core/types/block.go b/core/types/block.go index cd8607c23f..815b7b64d4 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -988,15 +988,6 @@ type Block struct { ReceivedFrom interface{} } -// "external" block encoding. used for eth protocol, etc. -type extblock struct { - Header *Header - Txs []*Transaction - Uncles []*Header - Etxs []*Transaction - SubManifest BlockManifest -} - func NewBlock(header *Header, txs []*Transaction, uncles []*Header, etxs []*Transaction, subManifest BlockManifest, receipts []*Receipt, hasher TrieHasher, nodeCtx int) *Block { b := &Block{header: CopyHeader(header)} @@ -1104,29 +1095,6 @@ func CopyHeader(h *Header) *Header { return &cpy } -// DecodeRLP decodes the Quai RLP encoding into b. -func (b *Block) DecodeRLP(s *rlp.Stream) error { - var eb extblock - _, size, _ := s.Kind() - if err := s.Decode(&eb); err != nil { - return err - } - b.header, b.uncles, b.transactions, b.extTransactions, b.subManifest = eb.Header, eb.Uncles, eb.Txs, eb.Etxs, eb.SubManifest - b.size.Store(common.StorageSize(rlp.ListSize(size))) - return nil -} - -// EncodeRLP serializes b into the Quai RLP block format. -func (b *Block) EncodeRLP(w io.Writer) error { - return rlp.Encode(w, extblock{ - Header: b.header, - Txs: b.transactions, - Uncles: b.uncles, - Etxs: b.extTransactions, - SubManifest: b.subManifest, - }) -} - // ProtoEncode serializes h into the Quai Proto Block format func (b *Block) ProtoEncode() (*ProtoBlock, error) { protoHeader, err := b.header.ProtoEncode()