mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-28 14:27:16 +00:00
Moved code around
This commit is contained in:
parent
59d8dc3950
commit
c17381b853
@ -79,20 +79,10 @@ func (s *State) GetContract(addr []byte) *Contract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *State) UpdateContract(addr []byte, contract *Contract) {
|
func (s *State) UpdateContract(addr []byte, contract *Contract) {
|
||||||
|
s.states[string(addr)] = contract.state
|
||||||
s.trie.Update(string(addr), string(contract.RlpEncode()))
|
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) {
|
func (s *State) GetAccount(addr []byte) (account *Account) {
|
||||||
data := s.trie.Get(string(addr))
|
data := s.trie.Get(string(addr))
|
||||||
if data == "" {
|
if data == "" {
|
||||||
@ -153,3 +143,31 @@ func (s *State) Get(key []byte) (*ethutil.Value, ObjType) {
|
|||||||
|
|
||||||
return val, typ
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user