Added new insruction methods
This commit is contained in:
@ -11,6 +11,7 @@ type Contract struct {
|
||||
//state *ethutil.Trie
|
||||
state *State
|
||||
address []byte
|
||||
script []byte
|
||||
}
|
||||
|
||||
func NewContract(address []byte, Amount *big.Int, root []byte) *Contract {
|
||||
@ -45,6 +46,14 @@ func (c *Contract) GetMem(num *big.Int) *ethutil.Value {
|
||||
return c.Addr(nb)
|
||||
}
|
||||
|
||||
func (c *Contract) GetInstr(pc *big.Int) *ethutil.Value {
|
||||
if int64(len(c.script)-1) < pc.Int64() {
|
||||
return ethutil.NewValue(0)
|
||||
}
|
||||
|
||||
return ethutil.NewValueFromBytes([]byte{c.script[pc.Int64()]})
|
||||
}
|
||||
|
||||
func (c *Contract) SetMem(num *big.Int, val *ethutil.Value) {
|
||||
addr := ethutil.BigToBytes(num, 256)
|
||||
c.state.trie.Update(string(addr), string(val.Encode()))
|
||||
|
Reference in New Issue
Block a user