trie: dirty tracking
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user