Пример #1
0
func (db *MemDatabase) Print() {
	for key, val := range db.db {
		fmt.Printf("%x(%d): ", key, len(key))
		node := common.NewValueFromBytes(val)
		fmt.Printf("%q\n", node.Val)
	}
}
Пример #2
0
func (c *StateObject) GetInstr(pc *big.Int) *common.Value {
	if int64(len(c.code)-1) < pc.Int64() {
		return common.NewValue(0)
	}

	return common.NewValueFromBytes([]byte{c.code[pc.Int64()]})
}
Пример #3
0
func (self *Trie) trans(node Node) Node {
	switch node := node.(type) {
	case *HashNode:
		value := common.NewValueFromBytes(self.cache.Get(node.key))
		return self.mknode(value)
	default:
		return node
	}
}
Пример #4
0
func (c *StateObject) RlpDecode(data []byte) {
	decoder := common.NewValueFromBytes(data)
	c.nonce = decoder.Get(0).Uint()
	c.balance = decoder.Get(1).BigInt()
	c.trie = trie.NewSecure(decoder.Get(2).Bytes(), c.db)
	c.storage = make(map[string]common.Hash)
	c.gasPool = new(big.Int)

	c.codeHash = decoder.Get(3).Bytes()

	c.code, _ = c.db.Get(c.codeHash)
}
Пример #5
0
func (c *StateObject) RlpDecode(data []byte) {
	decoder := common.NewValueFromBytes(data)
	c.nonce = decoder.Get(0).Uint()
	c.balance = decoder.Get(1).BigInt()
	c.State = New(common.BytesToHash(decoder.Get(2).Bytes()), c.db) //New(trie.New(common.Config.Db, decoder.Get(2).Interface()))
	c.storage = make(map[string]*common.Value)
	c.gasPool = new(big.Int)

	c.codeHash = decoder.Get(3).Bytes()

	c.code, _ = c.db.Get(c.codeHash)
}
Пример #6
0
// Reset should only be called if the trie has been hashed
func (self *Trie) Reset() {
	self.mu.Lock()
	defer self.mu.Unlock()

	self.cache.Reset()

	if self.revisions.Len() > 0 {
		revision := self.revisions.Remove(self.revisions.Back()).([]byte)
		self.roothash = revision
	}
	value := common.NewValueFromBytes(self.cache.Get(self.roothash))
	self.root = self.mknode(value)
}
Пример #7
0
func New(root []byte, backend Backend) *Trie {
	trie := &Trie{}
	trie.revisions = list.New()
	trie.roothash = root
	if backend != nil {
		trie.cache = NewCache(backend)
	}

	if root != nil {
		value := common.NewValueFromBytes(trie.cache.Get(root))
		trie.root = trie.mknode(value)
	}

	return trie
}
Пример #8
0
func (c *StateObject) getAddr(addr common.Hash) *common.Value {
	return common.NewValueFromBytes([]byte(c.State.trie.Get(addr[:])))
}