Skip to content

Commit

Permalink
Remove the encode and decode rlp for block
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers committed Mar 28, 2024
1 parent 6ba42b1 commit 99b00d4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 49 deletions.
17 changes: 0 additions & 17 deletions core/headerchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
32 changes: 0 additions & 32 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 99b00d4

Please sign in to comment.