aboutsummaryrefslogtreecommitdiffstats
path: root/trie/fullnode.go
diff options
context:
space:
mode:
Diffstat (limited to 'trie/fullnode.go')
-rw-r--r--trie/fullnode.go33
1 files changed, 25 insertions, 8 deletions
diff --git a/trie/fullnode.go b/trie/fullnode.go
index 522fdb373..06edf6a60 100644
--- a/trie/fullnode.go
+++ b/trie/fullnode.go
@@ -1,17 +1,32 @@
-package trie
+// Copyright 2014 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
-import "fmt"
+package trie
type FullNode struct {
trie *Trie
nodes [17]Node
+ dirty bool
}
func NewFullNode(t *Trie) *FullNode {
return &FullNode{trie: t}
}
-func (self *FullNode) Dirty() bool { return true }
+func (self *FullNode) Dirty() bool { return self.dirty }
func (self *FullNode) Value() Node {
self.nodes[16] = self.trie.trans(self.nodes[16])
return self.nodes[16]
@@ -24,9 +39,10 @@ func (self *FullNode) Copy(t *Trie) Node {
nnode := NewFullNode(t)
for i, node := range self.nodes {
if node != nil {
- nnode.nodes[i] = node.Copy(t)
+ nnode.nodes[i] = node
}
}
+ nnode.dirty = true
return nnode
}
@@ -60,11 +76,8 @@ func (self *FullNode) RlpData() interface{} {
}
func (self *FullNode) set(k byte, value Node) {
- if _, ok := value.(*ValueNode); ok && k != 16 {
- fmt.Println(value, k)
- }
-
self.nodes[int(k)] = value
+ self.dirty = true
}
func (self *FullNode) branch(i byte) Node {
@@ -75,3 +88,7 @@ func (self *FullNode) branch(i byte) Node {
}
return nil
}
+
+func (self *FullNode) setDirty(dirty bool) {
+ self.dirty = dirty
+}