diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-18 19:02:13 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-18 19:02:13 +0800 |
commit | f7417d3552de86f5acf969b6eb882502fd104a11 (patch) | |
tree | 939043bfbb72510326446b022e4615d58616e2e3 /ptrie/shortnode.go | |
parent | a19d2c22782fa85cd38de246d9801fa1ebd0660a (diff) | |
download | dexon-f7417d3552de86f5acf969b6eb882502fd104a11.tar dexon-f7417d3552de86f5acf969b6eb882502fd104a11.tar.gz dexon-f7417d3552de86f5acf969b6eb882502fd104a11.tar.bz2 dexon-f7417d3552de86f5acf969b6eb882502fd104a11.tar.lz dexon-f7417d3552de86f5acf969b6eb882502fd104a11.tar.xz dexon-f7417d3552de86f5acf969b6eb882502fd104a11.tar.zst dexon-f7417d3552de86f5acf969b6eb882502fd104a11.zip |
New modified patricia trie
Diffstat (limited to 'ptrie/shortnode.go')
-rw-r--r-- | ptrie/shortnode.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ptrie/shortnode.go b/ptrie/shortnode.go new file mode 100644 index 000000000..49319c555 --- /dev/null +++ b/ptrie/shortnode.go @@ -0,0 +1,31 @@ +package ptrie + +import "github.com/ethereum/go-ethereum/trie" + +type ShortNode struct { + trie *Trie + key []byte + value Node +} + +func NewShortNode(t *Trie, key []byte, value Node) *ShortNode { + return &ShortNode{t, []byte(trie.CompactEncode(key)), value} +} +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) Copy() Node { return self } + +func (self *ShortNode) RlpData() interface{} { + return []interface{}{self.key, self.value.Hash()} +} +func (self *ShortNode) Hash() interface{} { + return self.trie.store(self) +} + +func (self *ShortNode) Key() []byte { + return trie.CompactDecode(string(self.key)) +} |