Skip to content

Commit

Permalink
fix main lint (#12587)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Nov 3, 2024
1 parent f617c43 commit 00cf8eb
Showing 1 changed file with 0 additions and 129 deletions.
129 changes: 0 additions & 129 deletions erigon-lib/state/state_recon.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ package state

import (
"bytes"
"encoding/binary"

"github.com/erigontech/erigon-lib/recsplit"
"github.com/erigontech/erigon-lib/recsplit/eliasfano32"
"github.com/erigontech/erigon-lib/seg"
)

Expand Down Expand Up @@ -90,129 +87,3 @@ func (rh ReconHeapOlderFirst) Less(i, j int) bool {
}
return c < 0
}

type ScanIteratorInc struct {
g *seg.Getter
key []byte
nextTxNum uint64
hasNext bool
}

func (sii *ScanIteratorInc) advance() {
if !sii.hasNext {
return
}
if sii.key == nil {
sii.hasNext = false
return
}
val, _ := sii.g.NextUncompressed()
max := eliasfano32.Max(val)
sii.nextTxNum = max
if sii.g.HasNext() {
sii.key, _ = sii.g.NextUncompressed()
} else {
sii.key = nil
}
}

func (sii *ScanIteratorInc) HasNext() bool {
return sii.hasNext
}

func (sii *ScanIteratorInc) Next() (uint64, error) {
n := sii.nextTxNum
sii.advance()
return n, nil
}

func (hs *HistoryStep) iterateTxs() *ScanIteratorInc {
var sii ScanIteratorInc
sii.g = hs.indexFile.getter
sii.g.Reset(0)
if sii.g.HasNext() {
sii.key, _ = sii.g.NextUncompressed()
sii.hasNext = true
} else {
sii.hasNext = false
}
sii.advance()
return &sii
}

type HistoryIteratorInc struct {
uptoTxNum uint64
indexG *seg.Getter
historyG *seg.Getter
r *recsplit.IndexReader
key []byte
nextKey []byte
nextVal []byte
hasNext bool
compressVals bool
}

func (hs *HistoryStep) interateHistoryBeforeTxNum(txNum uint64) *HistoryIteratorInc {
var hii HistoryIteratorInc
hii.indexG = hs.indexFile.getter
hii.historyG = hs.historyFile.getter
hii.r = hs.historyFile.reader
hii.compressVals = hs.compressVals
hii.indexG.Reset(0)
if hii.indexG.HasNext() {
hii.key, _ = hii.indexG.NextUncompressed()
hii.uptoTxNum = txNum
hii.hasNext = true
} else {
hii.hasNext = false
}
hii.advance()
return &hii
}

func (hii *HistoryIteratorInc) advance() {
if !hii.hasNext {
return
}
if hii.key == nil {
hii.hasNext = false
return
}
hii.nextKey = nil
for hii.nextKey == nil && hii.key != nil {
val, _ := hii.indexG.NextUncompressed()
n, ok := eliasfano32.Seek(val, hii.uptoTxNum)
if ok {
var txKey [8]byte
binary.BigEndian.PutUint64(txKey[:], n)
offset, ok := hii.r.Lookup2(txKey[:], hii.key)
if ok {
hii.historyG.Reset(offset)
hii.nextKey = hii.key
if hii.compressVals {
hii.nextVal, _ = hii.historyG.Next(nil)
} else {
hii.nextVal, _ = hii.historyG.NextUncompressed()
}
}
}
if hii.indexG.HasNext() {
hii.key, _ = hii.indexG.NextUncompressed()
} else {
hii.key = nil
}
}
if hii.nextKey == nil {
hii.hasNext = false
}
}

func (hii *HistoryIteratorInc) HasNext() bool {
return hii.hasNext
}

func (hii *HistoryIteratorInc) Next() ([]byte, []byte, error) {
k, v := hii.nextKey, hii.nextVal
hii.advance()
return k, v, nil
}

0 comments on commit 00cf8eb

Please sign in to comment.