aboutsummaryrefslogtreecommitdiffstats
path: root/trie/shortnode.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-01 21:38:32 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-04 08:51:36 +0800
commit0a1ff68c11706f60355b392cb16a681630260ac3 (patch)
treefa7e46110a346cc1a10e3a3135815942c4560859 /trie/shortnode.go
parentab16ce70fc68d9ab1b7d8cda57c180b4785cab6a (diff)
downloadgo-tangerine-0a1ff68c11706f60355b392cb16a681630260ac3.tar
go-tangerine-0a1ff68c11706f60355b392cb16a681630260ac3.tar.gz
go-tangerine-0a1ff68c11706f60355b392cb16a681630260ac3.tar.bz2
go-tangerine-0a1ff68c11706f60355b392cb16a681630260ac3.tar.lz
go-tangerine-0a1ff68c11706f60355b392cb16a681630260ac3.tar.xz
go-tangerine-0a1ff68c11706f60355b392cb16a681630260ac3.tar.zst
go-tangerine-0a1ff68c11706f60355b392cb16a681630260ac3.zip
trie: dirty tracking
Diffstat (limited to 'trie/shortnode.go')
-rw-r--r--trie/shortnode.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/trie/shortnode.go b/trie/shortnode.go
index edd490b4d..c86e50096 100644
--- a/trie/shortnode.go
+++ b/trie/shortnode.go
@@ -6,20 +6,22 @@ type ShortNode struct {
trie *Trie
key []byte
value Node
+ dirty bool
}
func NewShortNode(t *Trie, key []byte, value Node) *ShortNode {
- return &ShortNode{t, []byte(CompactEncode(key)), value}
+ return &ShortNode{t, []byte(CompactEncode(key)), value, false}
}
func (self *ShortNode) Value() Node {
self.value = self.trie.trans(self.value)
return self.value
}
-func (self *ShortNode) Dirty() bool { return true }
+func (self *ShortNode) Dirty() bool { return self.dirty }
func (self *ShortNode) Copy(t *Trie) Node {
- node := &ShortNode{t, nil, self.value.Copy(t)}
+ node := &ShortNode{t, nil, self.value.Copy(t), self.dirty}
node.key = common.CopyBytes(self.key)
+ node.dirty = true
return node
}
@@ -33,3 +35,7 @@ func (self *ShortNode) Hash() interface{} {
func (self *ShortNode) Key() []byte {
return CompactDecode(string(self.key))
}
+
+func (self *ShortNode) setDirty(dirty bool) {
+ self.dirty = dirty
+}