diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-09 20:08:18 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-09 20:08:18 +0800 |
commit | c0a030ef0a3ce8342fda2a53cdafd50a271b4837 (patch) | |
tree | d3e5c71b4d1c4ef405a25f5ddd512687d01685ec /ethchain/contract.go | |
parent | 90bb512f420f204f50ba451a4a25682ca8443746 (diff) | |
download | dexon-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar dexon-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.gz dexon-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.bz2 dexon-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.lz dexon-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.xz dexon-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.tar.zst dexon-c0a030ef0a3ce8342fda2a53cdafd50a271b4837.zip |
Added new insruction methods
Diffstat (limited to 'ethchain/contract.go')
-rw-r--r-- | ethchain/contract.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ethchain/contract.go b/ethchain/contract.go index f7ae01753..f68dcf367 100644 --- a/ethchain/contract.go +++ b/ethchain/contract.go @@ -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())) |