// casting functions and cache storing func (self *Trie) mknode(value *common.Value) Node { l := value.Len() switch l { case 0: return nil case 2: // A value node may consists of 2 bytes. if value.Get(0).Len() != 0 { key := CompactDecode(value.Get(0).Bytes()) if key[len(key)-1] == 16 { return NewShortNode(self, key, NewValueNode(self, value.Get(1).Bytes())) } else { return NewShortNode(self, key, self.mknode(value.Get(1))) } } case 17: if len(value.Bytes()) != 17 { fnode := NewFullNode(self) for i := 0; i < 16; i++ { fnode.set(byte(i), self.mknode(value.Get(i))) } return fnode } case 32: return NewHash(value.Bytes(), self) } return NewValueNode(self, value.Bytes()) }
func (self *Object) StorageValue(addr *common.Value) []byte { return self.storage(addr.Bytes()) }