本文整理匯總了Golang中github.com/ethereum/go-ethereum/common.NewValueFromBytes函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewValueFromBytes函數的具體用法?Golang NewValueFromBytes怎麽用?Golang NewValueFromBytes使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewValueFromBytes函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Print
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: GetInstr
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: trans
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: RlpDecode
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: RlpDecode
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: Reset
// 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: New
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: getAddr
func (c *StateObject) getAddr(addr common.Hash) *common.Value {
return common.NewValueFromBytes([]byte(c.State.trie.Get(addr[:])))
}