aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-03-21 00:26:51 +0800
committerobscuren <geffobscura@gmail.com>2014-03-21 00:26:51 +0800
commitc17381b853e2d762787ca30c5ce45aeece99dfd1 (patch)
tree723cf6f4e6fb32c634d72ef11e6ad48c88d9f04f /ethchain
parent59d8dc39505981d1ae07b05a71d3f4cf1f33319a (diff)
downloadgo-tangerine-c17381b853e2d762787ca30c5ce45aeece99dfd1.tar
go-tangerine-c17381b853e2d762787ca30c5ce45aeece99dfd1.tar.gz
go-tangerine-c17381b853e2d762787ca30c5ce45aeece99dfd1.tar.bz2
go-tangerine-c17381b853e2d762787ca30c5ce45aeece99dfd1.tar.lz
go-tangerine-c17381b853e2d762787ca30c5ce45aeece99dfd1.tar.xz
go-tangerine-c17381b853e2d762787ca30c5ce45aeece99dfd1.tar.zst
go-tangerine-c17381b853e2d762787ca30c5ce45aeece99dfd1.zip
Moved code around
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/state.go40
1 files changed, 29 insertions, 11 deletions
diff --git a/ethchain/state.go b/ethchain/state.go
index b9c2c576d..b84d60c6c 100644
--- a/ethchain/state.go
+++ b/ethchain/state.go
@@ -79,20 +79,10 @@ func (s *State) GetContract(addr []byte) *Contract {
}
func (s *State) UpdateContract(addr []byte, contract *Contract) {
+ s.states[string(addr)] = contract.state
s.trie.Update(string(addr), string(contract.RlpEncode()))
}
-func Compile(code []string) (script []string) {
- script = make([]string, len(code))
- for i, val := range code {
- instr, _ := ethutil.CompileInstr(val)
-
- script[i] = string(instr)
- }
-
- return
-}
-
func (s *State) GetAccount(addr []byte) (account *Account) {
data := s.trie.Get(string(addr))
if data == "" {
@@ -153,3 +143,31 @@ func (s *State) Get(key []byte) (*ethutil.Value, ObjType) {
return val, typ
}
+
+func (s *State) Put(key, object []byte) {
+ s.trie.Update(string(key), string(object))
+}
+
+// Script compilation functions
+// Compiles strings to machine code
+func Compile(code []string) (script []string) {
+ script = make([]string, len(code))
+ for i, val := range code {
+ instr, _ := ethutil.CompileInstr(val)
+
+ script[i] = string(instr)
+ }
+
+ return
+}
+
+func CompileToValues(code []string) (script []*ethutil.Value) {
+ script = make([]*ethutil.Value, len(code))
+ for i, val := range code {
+ instr, _ := ethutil.CompileInstr(val)
+
+ script[i] = ethutil.NewValue(instr)
+ }
+
+ return
+}