trie: remove unused field dirtyCount

This commit is contained in:
Martin Holst Swende 2020-02-04 12:38:10 +01:00
parent 5f0d62c7db
commit e0c1fec36a
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -48,10 +48,6 @@ type LeafCallback func(leaf []byte, parent common.Hash) error
type Trie struct { type Trie struct {
db *Database db *Database
root node root node
// Keep a track of the number of leafs to commit. This counter is
// update for inserts and deletions of leafs, but does not accurately track the number
// of nodes
dirtyCount int
// Keep track of the number leafs which have been inserted since the last // Keep track of the number leafs which have been inserted since the last
// hashing operation. This number will not directly map to the number of // hashing operation. This number will not directly map to the number of
// actually unhashed nodes // actually unhashed nodes
@ -172,7 +168,6 @@ func (t *Trie) Update(key, value []byte) {
// If a node was not found in the database, a MissingNodeError is returned. // If a node was not found in the database, a MissingNodeError is returned.
func (t *Trie) TryUpdate(key, value []byte) error { func (t *Trie) TryUpdate(key, value []byte) error {
t.unhashedCount++ t.unhashedCount++
t.dirtyCount++
k := keybytesToHex(key) k := keybytesToHex(key)
if len(value) != 0 { if len(value) != 0 {
_, n, err := t.insert(t.root, nil, k, valueNode(value)) _, n, err := t.insert(t.root, nil, k, valueNode(value))
@ -270,7 +265,6 @@ func (t *Trie) Delete(key []byte) {
// If a node was not found in the database, a MissingNodeError is returned. // If a node was not found in the database, a MissingNodeError is returned.
func (t *Trie) TryDelete(key []byte) error { func (t *Trie) TryDelete(key []byte) error {
t.unhashedCount++ t.unhashedCount++
t.dirtyCount++
k := keybytesToHex(key) k := keybytesToHex(key)
_, n, err := t.delete(t.root, nil, k) _, n, err := t.delete(t.root, nil, k)
if err != nil { if err != nil {
@ -463,7 +457,6 @@ func (t *Trie) Commit(onleaf LeafCallback) (root common.Hash, err error) {
if err != nil { if err != nil {
return common.Hash{}, err return common.Hash{}, err
} }
t.dirtyCount = 0
t.root = newRoot t.root = newRoot
return rootHash, nil return rootHash, nil
} }