mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
trie, triedb/pathdb: address comment
This commit is contained in:
parent
ef42ebbcb1
commit
0104c64075
3 changed files with 6 additions and 7 deletions
|
|
@ -55,6 +55,9 @@ func newEmptyReader() *trieReader {
|
||||||
// node retrieves the rlp-encoded trie node with the provided trie node
|
// node retrieves the rlp-encoded trie node with the provided trie node
|
||||||
// information. An MissingNodeError will be returned in case the node is
|
// information. An MissingNodeError will be returned in case the node is
|
||||||
// not found or any error is encountered.
|
// not found or any error is encountered.
|
||||||
|
//
|
||||||
|
// Don't modify the returned byte slice since it's not deep-copied and
|
||||||
|
// still be referenced by database.
|
||||||
func (r *trieReader) node(path []byte, hash common.Hash) ([]byte, error) {
|
func (r *trieReader) node(path []byte, hash common.Hash) ([]byte, error) {
|
||||||
// Perform the logics in tests for preventing trie node access.
|
// Perform the logics in tests for preventing trie node access.
|
||||||
if r.banned != nil {
|
if r.banned != nil {
|
||||||
|
|
|
||||||
|
|
@ -104,11 +104,6 @@ func (b *buffer) size() uint64 {
|
||||||
return b.nodes.size
|
return b.nodes.size
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocBatch returns a database batch with pre-allocated buffer.
|
|
||||||
func (b *buffer) allocBatch(db ethdb.KeyValueStore) ethdb.Batch {
|
|
||||||
return db.NewBatchWithSize(b.nodes.dbsize() * 11 / 10) // extra 10% for potential pebble internal stuff
|
|
||||||
}
|
|
||||||
|
|
||||||
// flush persists the in-memory dirty trie node into the disk if the configured
|
// flush persists the in-memory dirty trie node into the disk if the configured
|
||||||
// memory threshold is reached. Note, all data must be written atomically.
|
// memory threshold is reached. Note, all data must be written atomically.
|
||||||
func (b *buffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, nodesCache *fastcache.Cache, id uint64) error {
|
func (b *buffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, nodesCache *fastcache.Cache, id uint64) error {
|
||||||
|
|
@ -120,7 +115,7 @@ func (b *buffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, node
|
||||||
// Terminate the state snapshot generation if it's active
|
// Terminate the state snapshot generation if it's active
|
||||||
var (
|
var (
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
batch = b.allocBatch(db)
|
batch = db.NewBatchWithSize(b.nodes.dbsize() * 11 / 10) // extra 10% for potential pebble internal stuff
|
||||||
)
|
)
|
||||||
// Explicitly sync the state freezer, ensuring that all written
|
// Explicitly sync the state freezer, ensuring that all written
|
||||||
// data is transferred to disk before updating the key-value store.
|
// data is transferred to disk before updating the key-value store.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/trie/trienode"
|
"github.com/ethereum/go-ethereum/trie/trienode"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nodeCacheKey constructs the unique key of clean cache.
|
// nodeCacheKey constructs the unique key of clean cache. The assumption is held
|
||||||
|
// that zero address does not have any associated storage slots.
|
||||||
func nodeCacheKey(owner common.Hash, path []byte) []byte {
|
func nodeCacheKey(owner common.Hash, path []byte) []byte {
|
||||||
if owner == (common.Hash{}) {
|
if owner == (common.Hash{}) {
|
||||||
return path
|
return path
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue