mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Fix txIndexer
This commit is contained in:
parent
a902cd12a4
commit
352fb8adfa
4 changed files with 9 additions and 7 deletions
|
|
@ -539,12 +539,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
||||||
rawdb.WriteChainConfig(db, genesisHash, chainConfig)
|
rawdb.WriteChainConfig(db, genesisHash, chainConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
if txLookupLimit == nil {
|
if txLookupLimit != nil {
|
||||||
txLookupLimit = new(uint64)
|
txLookupLimit = new(uint64)
|
||||||
*txLookupLimit = txLookupCacheLimit
|
*txLookupLimit = txLookupCacheLimit
|
||||||
}
|
|
||||||
|
|
||||||
bc.txIndexer = newTxIndexer(*txLookupLimit, bc)
|
bc.txIndexer = newTxIndexer(*txLookupLimit, bc)
|
||||||
|
}
|
||||||
|
|
||||||
return bc, nil
|
return bc, nil
|
||||||
}
|
}
|
||||||
|
|
@ -1569,7 +1568,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
||||||
// generated.
|
// generated.
|
||||||
batch := bc.db.NewBatch()
|
batch := bc.db.NewBatch()
|
||||||
for i, block := range blockChain {
|
for i, block := range blockChain {
|
||||||
if bc.txIndexer.limit == 0 || ancientLimit <= bc.txIndexer.limit || block.NumberU64() >= ancientLimit-bc.txIndexer.limit {
|
if bc.txIndexer == nil || bc.txIndexer.limit == 0 || ancientLimit <= bc.txIndexer.limit || block.NumberU64() >= ancientLimit-bc.txIndexer.limit {
|
||||||
rawdb.WriteTxLookupEntriesByBlock(batch, block)
|
rawdb.WriteTxLookupEntriesByBlock(batch, block)
|
||||||
} else if rawdb.ReadTxIndexTail(bc.db) != nil {
|
} else if rawdb.ReadTxIndexTail(bc.db) != nil {
|
||||||
rawdb.WriteTxLookupEntriesByBlock(batch, block)
|
rawdb.WriteTxLookupEntriesByBlock(batch, block)
|
||||||
|
|
|
||||||
|
|
@ -439,12 +439,18 @@ func (bc *BlockChain) GetVMConfig() *vm.Config {
|
||||||
// SetTxLookupLimit is responsible for updating the txlookup limit to the
|
// SetTxLookupLimit is responsible for updating the txlookup limit to the
|
||||||
// original one stored in db if the new mismatches with the old one.
|
// original one stored in db if the new mismatches with the old one.
|
||||||
func (bc *BlockChain) SetTxLookupLimit(limit uint64) {
|
func (bc *BlockChain) SetTxLookupLimit(limit uint64) {
|
||||||
|
if bc.txIndexer == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
bc.txIndexer.limit = limit
|
bc.txIndexer.limit = limit
|
||||||
}
|
}
|
||||||
|
|
||||||
// TxLookupLimit retrieves the txlookup limit used by blockchain to prune
|
// TxLookupLimit retrieves the txlookup limit used by blockchain to prune
|
||||||
// stale transaction indices.
|
// stale transaction indices.
|
||||||
func (bc *BlockChain) TxLookupLimit() uint64 {
|
func (bc *BlockChain) TxLookupLimit() uint64 {
|
||||||
|
if bc.txIndexer == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
return bc.txIndexer.limit
|
return bc.txIndexer.limit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1790,7 +1790,6 @@ func testLongReorgedSnapSyncingDeepRepair(t *testing.T, snapshots bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
|
func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
|
||||||
t.Parallel()
|
|
||||||
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
|
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
|
||||||
testRepairWithScheme(t, tt, snapshots, scheme)
|
testRepairWithScheme(t, tt, snapshots, scheme)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -531,7 +531,6 @@ func TestLowCommitCrashWithNewSnapshot(t *testing.T) {
|
||||||
// Expected head block : C2
|
// Expected head block : C2
|
||||||
// Expected snapshot disk : C4
|
// Expected snapshot disk : C4
|
||||||
|
|
||||||
t.Parallel()
|
|
||||||
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
|
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
|
||||||
test := &crashSnapshotTest{
|
test := &crashSnapshotTest{
|
||||||
snapshotTestBasic{
|
snapshotTestBasic{
|
||||||
|
|
@ -575,7 +574,6 @@ func TestHighCommitCrashWithNewSnapshot(t *testing.T) {
|
||||||
// Expected head block : G
|
// Expected head block : G
|
||||||
// Expected snapshot disk : C4
|
// Expected snapshot disk : C4
|
||||||
|
|
||||||
t.Parallel()
|
|
||||||
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
|
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
|
||||||
expHead := uint64(0)
|
expHead := uint64(0)
|
||||||
if scheme == rawdb.PathScheme {
|
if scheme == rawdb.PathScheme {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue