Skip to content

Commit b4caf19

Browse files
committed
core: rename stateDb
1 parent c4a2101 commit b4caf19

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

core/blockchain.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ type BlockChain struct {
217217
lastWrite uint64 // Last block when the state was flushed
218218
flushInterval atomic.Int64 // Time interval (processing time) after which to flush a state
219219
triedb *triedb.Database // The database handler for maintaining trie nodes.
220-
stateDb *state.CachingDB // State database to reuse between imports (contains state cache)
220+
statedb *state.CachingDB // State database to reuse between imports (contains state cache)
221221
txIndexer *txIndexer // Transaction indexer, might be nil if not enabled
222222

223223
hc *HeaderChain
@@ -308,7 +308,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
308308
return nil, err
309309
}
310310
bc.flushInterval.Store(int64(cacheConfig.TrieTimeLimit))
311-
bc.stateDb = state.NewDatabase(bc.triedb, nil)
311+
bc.statedb = state.NewDatabase(bc.triedb, nil)
312312
bc.validator = NewBlockValidator(chainConfig, bc)
313313
bc.prefetcher = newStatePrefetcher(chainConfig, bc.hc)
314314
bc.processor = NewStateProcessor(chainConfig, bc.hc)
@@ -448,7 +448,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
448448
bc.snaps, _ = snapshot.New(snapconfig, bc.db, bc.triedb, head.Root)
449449

450450
// Re-initialize the state database with snapshot
451-
bc.stateDb = state.NewDatabase(bc.triedb, bc.snaps)
451+
bc.statedb = state.NewDatabase(bc.triedb, bc.snaps)
452452
}
453453

454454
// Rewind the chain in case of an incompatible config upgrade.
@@ -1768,7 +1768,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
17681768
if parent == nil {
17691769
parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
17701770
}
1771-
statedb, err := state.New(parent.Root, bc.stateDb)
1771+
statedb, err := state.New(parent.Root, bc.statedb)
17721772
if err != nil {
17731773
return it.index, err
17741774
}
@@ -1794,7 +1794,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
17941794
var followupInterrupt atomic.Bool
17951795
if !bc.cacheConfig.TrieCleanNoPrefetch {
17961796
if followup, err := it.peek(); followup != nil && err == nil {
1797-
throwaway, _ := state.New(parent.Root, bc.stateDb)
1797+
throwaway, _ := state.New(parent.Root, bc.statedb)
17981798

17991799
go func(start time.Time, followup *types.Block, throwaway *state.StateDB) {
18001800
// Disable tracing for prefetcher executions.

core/blockchain_reader.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (bc *BlockChain) GetTd(hash common.Hash, number uint64) *big.Int {
308308

309309
// HasState checks if state trie is fully present in the database or not.
310310
func (bc *BlockChain) HasState(hash common.Hash) bool {
311-
_, err := bc.stateDb.OpenTrie(hash)
311+
_, err := bc.statedb.OpenTrie(hash)
312312
return err == nil
313313
}
314314

@@ -343,7 +343,7 @@ func (bc *BlockChain) stateRecoverable(root common.Hash) bool {
343343
func (bc *BlockChain) ContractCodeWithPrefix(hash common.Hash) ([]byte, error) {
344344
// TODO(rjl493456442) The associated account address is also required
345345
// in Verkle scheme. Fix it once snap-sync is supported for Verkle.
346-
return bc.stateDb.ContractCodeWithPrefix(common.Address{}, hash)
346+
return bc.statedb.ContractCodeWithPrefix(common.Address{}, hash)
347347
}
348348

349349
// State returns a new mutable state based on the current HEAD block.
@@ -353,7 +353,7 @@ func (bc *BlockChain) State() (*state.StateDB, error) {
353353

354354
// StateAt returns a new mutable state based on a particular point in time.
355355
func (bc *BlockChain) StateAt(root common.Hash) (*state.StateDB, error) {
356-
return state.New(root, bc.stateDb)
356+
return state.New(root, bc.statedb)
357357
}
358358

359359
// Config retrieves the chain's fork configuration.
@@ -379,7 +379,7 @@ func (bc *BlockChain) Processor() Processor {
379379

380380
// StateCache returns the caching database underpinning the blockchain instance.
381381
func (bc *BlockChain) StateCache() state.Database {
382-
return bc.stateDb
382+
return bc.statedb
383383
}
384384

385385
// GasLimit returns the gas limit of the current HEAD block.

core/blockchain_sethead_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ func testSetHeadWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme
20402040
dbconfig.HashDB = hashdb.Defaults
20412041
}
20422042
chain.triedb = triedb.NewDatabase(chain.db, dbconfig)
2043-
chain.stateDb = state.NewDatabase(chain.triedb, chain.snaps)
2043+
chain.statedb = state.NewDatabase(chain.triedb, chain.snaps)
20442044

20452045
// Force run a freeze cycle
20462046
type freezer interface {

core/blockchain_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
160160
}
161161
return err
162162
}
163-
statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.stateDb)
163+
statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.statedb)
164164
if err != nil {
165165
return err
166166
}

0 commit comments

Comments
 (0)