2014-10-31 15:43:14 +02:00
|
|
|
package state
|
2014-10-27 12:44:16 +02:00
|
|
|
|
2014-10-29 11:34:40 +02:00
|
|
|
import "github.com/ethereum/go-ethereum/ethutil"
|
2014-10-27 12:44:16 +02:00
|
|
|
|
|
|
|
type Log struct {
|
|
|
|
Address []byte
|
2014-10-29 11:34:40 +02:00
|
|
|
Topics [][]byte
|
2014-10-27 12:44:16 +02:00
|
|
|
Data []byte
|
|
|
|
}
|
2014-10-29 11:34:40 +02:00
|
|
|
|
|
|
|
func NewLogFromValue(decoder *ethutil.Value) Log {
|
|
|
|
log := Log{
|
|
|
|
Address: decoder.Get(0).Bytes(),
|
|
|
|
Data: decoder.Get(2).Bytes(),
|
|
|
|
}
|
|
|
|
|
|
|
|
it := decoder.Get(1).NewIterator()
|
|
|
|
for it.Next() {
|
|
|
|
log.Topics = append(log.Topics, it.Value().Bytes())
|
|
|
|
}
|
|
|
|
|
|
|
|
return log
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self Log) RlpData() interface{} {
|
|
|
|
return []interface{}{self.Address, ethutil.ByteSliceToInterface(self.Topics), self.Data}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Logs []Log
|
|
|
|
|
|
|
|
func (self Logs) RlpData() interface{} {
|
|
|
|
data := make([]interface{}, len(self))
|
|
|
|
for i, log := range self {
|
|
|
|
data[i] = log.RlpData()
|
|
|
|
}
|
|
|
|
|
|
|
|
return data
|
|
|
|
}
|