mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
blockReader: read blockNum == r.FrozenBlocks()
from files (#8890)
Example value of `r.FrozenBlocks()`: `499999` In future PR I will rename this method to something like `MaxBlockNumInFiles()`
This commit is contained in:
parent
df9b47478c
commit
9bea4e3a9c
@ -439,8 +439,8 @@ func (r *BlockReader) BodyRlp(ctx context.Context, tx kv.Getter, hash common.Has
|
||||
}
|
||||
|
||||
func (r *BlockReader) Body(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (body *types.Body, txAmount uint32, err error) {
|
||||
blocksAvailable := r.sn.BlocksAvailable()
|
||||
if blocksAvailable == 0 || blockHeight > blocksAvailable {
|
||||
maxBlockNumInFiles := r.sn.BlocksAvailable()
|
||||
if maxBlockNumInFiles == 0 || blockHeight > maxBlockNumInFiles {
|
||||
body, _, txAmount = rawdb.ReadBody(tx, hash, blockHeight)
|
||||
return body, txAmount, nil
|
||||
}
|
||||
@ -459,8 +459,8 @@ func (r *BlockReader) Body(ctx context.Context, tx kv.Getter, hash common.Hash,
|
||||
}
|
||||
|
||||
func (r *BlockReader) HasSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64) (bool, error) {
|
||||
blocksAvailable := r.sn.BlocksAvailable()
|
||||
if blocksAvailable == 0 || blockHeight > blocksAvailable {
|
||||
maxBlockNumInFiles := r.sn.BlocksAvailable()
|
||||
if maxBlockNumInFiles == 0 || blockHeight > maxBlockNumInFiles {
|
||||
return rawdb.HasSenders(tx, hash, blockHeight)
|
||||
}
|
||||
return true, nil
|
||||
@ -470,8 +470,8 @@ func (r *BlockReader) BlockWithSenders(ctx context.Context, tx kv.Getter, hash c
|
||||
return r.blockWithSenders(ctx, tx, hash, blockHeight, false)
|
||||
}
|
||||
func (r *BlockReader) blockWithSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockHeight uint64, forceCanonical bool) (block *types.Block, senders []common.Address, err error) {
|
||||
blocksAvailable := r.sn.BlocksAvailable()
|
||||
if blocksAvailable == 0 || blockHeight > blocksAvailable {
|
||||
maxBlockNumInFiles := r.sn.BlocksAvailable()
|
||||
if maxBlockNumInFiles == 0 || blockHeight > maxBlockNumInFiles {
|
||||
if forceCanonical {
|
||||
canonicalHash, err := rawdb.ReadCanonicalHash(tx, blockHeight)
|
||||
if err != nil {
|
||||
@ -756,8 +756,8 @@ func (r *BlockReader) txnByHash(txnHash common.Hash, segments []*TxnSegment, buf
|
||||
// TxnByIdxInBlock - doesn't include system-transactions in the begin/end of block
|
||||
// return nil if 0 < i < body.TxAmount
|
||||
func (r *BlockReader) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, txIdxInBlock int) (txn types.Transaction, err error) {
|
||||
blocksAvailable := r.sn.BlocksAvailable()
|
||||
if blocksAvailable == 0 || blockNum > blocksAvailable {
|
||||
maxBlockNumInFiles := r.sn.BlocksAvailable()
|
||||
if maxBlockNumInFiles == 0 || blockNum > maxBlockNumInFiles {
|
||||
canonicalHash, err := rawdb.ReadCanonicalHash(tx, blockNum)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -991,7 +991,8 @@ func (r *BlockReader) borBlockByEventHash(txnHash common.Hash, segments []*BorEv
|
||||
}
|
||||
|
||||
func (r *BlockReader) EventsByBlock(ctx context.Context, tx kv.Tx, hash common.Hash, blockHeight uint64) ([]rlp.RawValue, error) {
|
||||
if blockHeight >= r.FrozenBorBlocks() {
|
||||
maxBlockNumInFiles := r.FrozenBorBlocks()
|
||||
if maxBlockNumInFiles == 0 || blockHeight > maxBlockNumInFiles {
|
||||
c, err := tx.Cursor(kv.BorEventNums)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1109,7 +1110,8 @@ func (r *BlockReader) Span(ctx context.Context, tx kv.Getter, spanId uint64) ([]
|
||||
}
|
||||
var buf [8]byte
|
||||
binary.BigEndian.PutUint64(buf[:], spanId)
|
||||
if endBlock >= r.FrozenBorBlocks() {
|
||||
maxBlockNumInFiles := r.FrozenBorBlocks()
|
||||
if maxBlockNumInFiles == 0 || endBlock > maxBlockNumInFiles {
|
||||
v, err := tx.GetOne(kv.BorSpans, buf[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -496,12 +496,12 @@ func (s *RoSnapshots) Files() (list []string) {
|
||||
defer s.Bodies.lock.RUnlock()
|
||||
s.Txs.lock.RLock()
|
||||
defer s.Txs.lock.RUnlock()
|
||||
max := s.BlocksAvailable()
|
||||
maxBlockNumInFiles := s.BlocksAvailable()
|
||||
for _, seg := range s.Bodies.segments {
|
||||
if seg.seg == nil {
|
||||
continue
|
||||
}
|
||||
if seg.ranges.from > max {
|
||||
if seg.ranges.from > maxBlockNumInFiles {
|
||||
continue
|
||||
}
|
||||
_, fName := filepath.Split(seg.seg.FilePath())
|
||||
@ -511,7 +511,7 @@ func (s *RoSnapshots) Files() (list []string) {
|
||||
if seg.seg == nil {
|
||||
continue
|
||||
}
|
||||
if seg.ranges.from > max {
|
||||
if seg.ranges.from > maxBlockNumInFiles {
|
||||
continue
|
||||
}
|
||||
_, fName := filepath.Split(seg.seg.FilePath())
|
||||
@ -521,7 +521,7 @@ func (s *RoSnapshots) Files() (list []string) {
|
||||
if seg.Seg == nil {
|
||||
continue
|
||||
}
|
||||
if seg.ranges.from > max {
|
||||
if seg.ranges.from > maxBlockNumInFiles {
|
||||
continue
|
||||
}
|
||||
_, fName := filepath.Split(seg.Seg.FilePath())
|
||||
|
Loading…
Reference in New Issue
Block a user