mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
only start pruning after bloom indexer catches up
This commit is contained in:
parent
e1f09e47f1
commit
86cd551061
2 changed files with 20 additions and 1 deletions
|
|
@ -2368,10 +2368,15 @@ func (bc *BlockChain) maintainTxIndex(ancients uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pruneTo := last - ancientLimit
|
pruneTo := last - ancientLimit
|
||||||
|
storedSections := rawdb.ReadStoredBloomSections(bc.db)
|
||||||
|
if storedSections*params.BloomBitsBlocks-1 < pruneTo {
|
||||||
|
log.Warn("Attempt to prune the ancient blocks that bloom filter haven't finished yet, postpone to next round", "storedSections", storedSections, "pruneTo", pruneTo)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Double ensure we don't prune the blocks having dangling transaction indices
|
// Double ensure we don't prune the blocks having dangling transaction indices
|
||||||
if txIndexTail != nil && pruneTo > *txIndexTail {
|
if txIndexTail != nil && pruneTo > *txIndexTail {
|
||||||
log.Warn("Attempt to prune the ancient blocks that still have tx indices, postpone to next round")
|
log.Warn("Attempt to prune the ancient blocks that still have tx indices, postpone to next round", "txIndexTail", *txIndexTail, "pruneTo", pruneTo)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package rawdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -141,6 +142,19 @@ func ReadReceipt(db ethdb.Reader, hash common.Hash, config *params.ChainConfig)
|
||||||
return nil, common.Hash{}, 0, 0
|
return nil, common.Hash{}, 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadStoredBloomSections reads the number of valid sections from the index database
|
||||||
|
func ReadStoredBloomSections(db ethdb.Database) uint64 {
|
||||||
|
var storedSections uint64
|
||||||
|
|
||||||
|
table := NewTable(db, string(BloomBitsIndexPrefix))
|
||||||
|
data, _ := table.Get([]byte("count"))
|
||||||
|
if len(data) == 8 {
|
||||||
|
storedSections = binary.BigEndian.Uint64(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
return storedSections
|
||||||
|
}
|
||||||
|
|
||||||
// ReadBloomBits retrieves the compressed bloom bit vector belonging to the given
|
// ReadBloomBits retrieves the compressed bloom bit vector belonging to the given
|
||||||
// section and bit index from the.
|
// section and bit index from the.
|
||||||
func ReadBloomBits(db ethdb.KeyValueReader, bit uint, section uint64, head common.Hash) ([]byte, error) {
|
func ReadBloomBits(db ethdb.KeyValueReader, bit uint, section uint64, head common.Hash) ([]byte, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue