Added new insruction methods

This commit is contained in:
obscuren
2014-04-09 14:08:18 +02:00
parent 90bb512f42
commit c0a030ef0a
3 changed files with 39 additions and 1 deletions

View File

@ -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()))