Log is now interface

This commit is contained in:
obscuren
2014-12-04 12:35:23 +01:00
parent bff5999efa
commit 3043b233ea
10 changed files with 75 additions and 30 deletions

View File

@ -20,7 +20,7 @@ type Environment interface {
BlockHash() []byte
GasLimit() *big.Int
Transfer(from, to Account, amount *big.Int) error
AddLog(*state.Log)
AddLog(state.Log)
Depth() int
SetDepth(i int)
@ -52,3 +52,25 @@ func Transfer(from, to Account, amount *big.Int) error {
return nil
}
type Log struct {
address []byte
topics [][]byte
data []byte
}
func (self *Log) Address() []byte {
return self.address
}
func (self *Log) Topics() [][]byte {
return self.topics
}
func (self *Log) Data() []byte {
return self.data
}
func (self *Log) RlpData() interface{} {
return []interface{}{self.address, ethutil.ByteSliceToInterface(self.topics), self.data}
}

View File

@ -35,7 +35,7 @@ func NewDebugVm(env Environment) *DebugVm {
lt = LogTyDiff
}
return &DebugVm{env: env, logTy: lt, Recoverable: false}
return &DebugVm{env: env, logTy: lt, Recoverable: true}
}
func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
@ -750,7 +750,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
topics[i] = ethutil.LeftPadBytes(stack.Pop().Bytes(), 32)
}
log := &state.Log{closure.Address(), topics, data}
log := &Log{closure.Address(), topics, data}
self.env.AddLog(log)
self.Printf(" => %v", log)