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
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"iter"
|
"iter"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Range represents a range of integers.
|
// 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}
|
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.
|
// First returns the first element of the range.
|
||||||
func (r Range[T]) First() T {
|
func (r Range[T]) First() T {
|
||||||
return r.first
|
return r.first
|
||||||
|
|
|
||||||
|
|
@ -202,8 +202,8 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, historyCutoff, f
|
||||||
initialized: initialized,
|
initialized: initialized,
|
||||||
headIndexed: rs.HeadIndexed,
|
headIndexed: rs.HeadIndexed,
|
||||||
headDelimiter: rs.HeadDelimiter,
|
headDelimiter: rs.HeadDelimiter,
|
||||||
blocks: rs.Blocks,
|
blocks: common.NewRange[uint64](rs.BlocksFirst, rs.BlocksAfterLast-rs.BlocksFirst),
|
||||||
maps: rs.Maps,
|
maps: common.NewRange[uint32](rs.MapsFirst, rs.MapsAfterLast-rs.MapsFirst),
|
||||||
tailPartialEpoch: rs.TailPartialEpoch,
|
tailPartialEpoch: rs.TailPartialEpoch,
|
||||||
},
|
},
|
||||||
matcherSyncCh: make(chan *FilterMapsMatcherBackend),
|
matcherSyncCh: make(chan *FilterMapsMatcherBackend),
|
||||||
|
|
@ -381,8 +381,10 @@ func (f *FilterMaps) setRange(batch ethdb.KeyValueWriter, newView *ChainView, ne
|
||||||
rs := rawdb.FilterMapsRange{
|
rs := rawdb.FilterMapsRange{
|
||||||
HeadIndexed: newRange.headIndexed,
|
HeadIndexed: newRange.headIndexed,
|
||||||
HeadDelimiter: newRange.headDelimiter,
|
HeadDelimiter: newRange.headDelimiter,
|
||||||
Blocks: newRange.blocks,
|
BlocksFirst: newRange.blocks.First(),
|
||||||
Maps: newRange.maps,
|
BlocksAfterLast: newRange.blocks.AfterLast(),
|
||||||
|
MapsFirst: newRange.maps.First(),
|
||||||
|
MapsAfterLast: newRange.maps.AfterLast(),
|
||||||
TailPartialEpoch: newRange.tailPartialEpoch,
|
TailPartialEpoch: newRange.tailPartialEpoch,
|
||||||
}
|
}
|
||||||
rawdb.WriteFilterMapsRange(batch, rs)
|
rawdb.WriteFilterMapsRange(batch, rs)
|
||||||
|
|
|
||||||
|
|
@ -442,11 +442,11 @@ func DeleteBlockLvPointers(db ethdb.KeyValueRangeDeleter, blocks common.Range[ui
|
||||||
// FilterMapsRange is a storage representation of the block range covered by the
|
// FilterMapsRange is a storage representation of the block range covered by the
|
||||||
// filter maps structure and the corresponting log value index range.
|
// filter maps structure and the corresponting log value index range.
|
||||||
type FilterMapsRange struct {
|
type FilterMapsRange struct {
|
||||||
HeadIndexed bool
|
HeadIndexed bool
|
||||||
HeadDelimiter uint64
|
HeadDelimiter uint64
|
||||||
Blocks common.Range[uint64]
|
BlocksFirst, BlocksAfterLast uint64
|
||||||
Maps common.Range[uint32]
|
MapsFirst, MapsAfterLast uint32
|
||||||
TailPartialEpoch uint32
|
TailPartialEpoch uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadFilterMapsRange retrieves the filter maps range data. Note that if the
|
// ReadFilterMapsRange retrieves the filter maps range data. Note that if the
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue