aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-04-18 19:37:10 +0800
committerFelix Lange <fjl@twurst.com>2017-04-25 08:14:31 +0800
commita13e920af01692cb07a520cda688f1cc5b5469dd (patch)
tree2321214787947ca0b4f302225aa2950617dd5cdd /core
parentf958d7d4822d257598ae36fc3b381040faa5bb30 (diff)
downloaddexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.gz
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.bz2
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.lz
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.xz
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.zst
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.zip
trie: clean up iterator constructors
Make it so each iterator has exactly one public constructor: - NodeIterators can be created through a method. - Iterators can be created through NewIterator on any NodeIterator.
Diffstat (limited to 'core')
-rw-r--r--core/state/dump.go5
-rw-r--r--core/state/iterator.go2
-rw-r--r--core/state/statedb.go2
3 files changed, 5 insertions, 4 deletions
diff --git a/core/state/dump.go b/core/state/dump.go
index 8294d61b9..6338ddf88 100644
--- a/core/state/dump.go
+++ b/core/state/dump.go
@@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
+ "github.com/ethereum/go-ethereum/trie"
)
type DumpAccount struct {
@@ -44,7 +45,7 @@ func (self *StateDB) RawDump() Dump {
Accounts: make(map[string]DumpAccount),
}
- it := self.trie.Iterator()
+ it := trie.NewIterator(self.trie.NodeIterator())
for it.Next() {
addr := self.trie.GetKey(it.Key)
var data Account
@@ -61,7 +62,7 @@ func (self *StateDB) RawDump() Dump {
Code: common.Bytes2Hex(obj.Code(self.db)),
Storage: make(map[string]string),
}
- storageIt := obj.getTrie(self.db).Iterator()
+ storageIt := trie.NewIterator(obj.getTrie(self.db).NodeIterator())
for storageIt.Next() {
account.Storage[common.Bytes2Hex(self.trie.GetKey(storageIt.Key))] = common.Bytes2Hex(storageIt.Value)
}
diff --git a/core/state/iterator.go b/core/state/iterator.go
index 170aec983..d2dd5a74e 100644
--- a/core/state/iterator.go
+++ b/core/state/iterator.go
@@ -118,7 +118,7 @@ func (it *NodeIterator) step() error {
if err != nil {
return err
}
- it.dataIt = trie.NewNodeIterator(dataTrie)
+ it.dataIt = dataTrie.NodeIterator()
if !it.dataIt.Next(true) {
it.dataIt = nil
}
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 0c72fc6b0..24381ced5 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -481,7 +481,7 @@ func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common
cb(h, value)
}
- it := so.getTrie(db.db).Iterator()
+ it := trie.NewIterator(so.getTrie(db.db).NodeIterator())
for it.Next() {
// ignore cached values
key := common.BytesToHash(db.trie.GetKey(it.Key))