mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
common, core/filtermaps: moved rlp encoding of Range to filtermaps
This commit is contained in:
parent
c9fd10147f
commit
8c3091edc1
3 changed files with 11 additions and 28 deletions
|
|
@ -17,10 +17,7 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"io"
|
||||
"iter"
|
||||
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
// Range represents a range of integers.
|
||||
|
|
@ -33,22 +30,6 @@ func NewRange[T uint32 | uint64](first, count T) Range[T] {
|
|||
return Range[T]{first, first + count}
|
||||
}
|
||||
|
||||
// EncodeRLP implements rlp.Encoder.
|
||||
func (r *Range[T]) EncodeRLP(w io.Writer) error {
|
||||
if err := rlp.Encode(w, &r.first); err != nil {
|
||||
return err
|
||||
}
|
||||
return rlp.Encode(w, &r.afterLast)
|
||||
}
|
||||
|
||||
// DecodeRLP implements rlp.Decoder.
|
||||
func (r *Range[T]) DecodeRLP(s *rlp.Stream) error {
|
||||
if err := s.Decode(&r.first); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.Decode(&r.afterLast)
|
||||
}
|
||||
|
||||
// First returns the first element of the range.
|
||||
func (r Range[T]) First() T {
|
||||
return r.first
|
||||
|
|
|
|||
|
|
@ -202,8 +202,8 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, f
|
|||
initialized: initialized,
|
||||
headIndexed: rs.HeadIndexed,
|
||||
headDelimiter: rs.HeadDelimiter,
|
||||
blocks: rs.Blocks,
|
||||
maps: rs.Maps,
|
||||
blocks: common.NewRange[uint64](rs.BlocksFirst, rs.BlocksAfterLast-rs.BlocksFirst),
|
||||
maps: common.NewRange[uint32](rs.MapsFirst, rs.MapsAfterLast-rs.MapsFirst),
|
||||
tailPartialEpoch: rs.TailPartialEpoch,
|
||||
},
|
||||
matcherSyncCh: make(chan *FilterMapsMatcherBackend),
|
||||
|
|
@ -381,8 +381,10 @@ func (f *FilterMaps) setRange(batch ethdb.KeyValueWriter, newView *ChainView, ne
|
|||
rs := rawdb.FilterMapsRange{
|
||||
HeadIndexed: newRange.headIndexed,
|
||||
HeadDelimiter: newRange.headDelimiter,
|
||||
Blocks: newRange.blocks,
|
||||
Maps: newRange.maps,
|
||||
BlocksFirst: newRange.blocks.First(),
|
||||
BlocksAfterLast: newRange.blocks.AfterLast(),
|
||||
MapsFirst: newRange.maps.First(),
|
||||
MapsAfterLast: newRange.maps.AfterLast(),
|
||||
TailPartialEpoch: newRange.tailPartialEpoch,
|
||||
}
|
||||
rawdb.WriteFilterMapsRange(batch, rs)
|
||||
|
|
|
|||
|
|
@ -444,8 +444,8 @@ func DeleteBlockLvPointers(db ethdb.KeyValueRangeDeleter, blocks common.Range[ui
|
|||
type FilterMapsRange struct {
|
||||
HeadIndexed bool
|
||||
HeadDelimiter uint64
|
||||
Blocks common.Range[uint64]
|
||||
Maps common.Range[uint32]
|
||||
BlocksFirst, BlocksAfterLast uint64
|
||||
MapsFirst, MapsAfterLast uint32
|
||||
TailPartialEpoch uint32
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue