mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
1.7 KiB
100 lines
1.7 KiB
10 years ago
|
package state
|
||
10 years ago
|
|
||
10 years ago
|
import (
|
||
|
"fmt"
|
||
10 years ago
|
"io"
|
||
10 years ago
|
|
||
10 years ago
|
"github.com/ethereum/go-ethereum/common"
|
||
10 years ago
|
"github.com/ethereum/go-ethereum/rlp"
|
||
10 years ago
|
)
|
||
10 years ago
|
|
||
10 years ago
|
type Log interface {
|
||
10 years ago
|
Address() common.Address
|
||
10 years ago
|
Topics() []common.Hash
|
||
10 years ago
|
Data() []byte
|
||
10 years ago
|
|
||
|
Number() uint64
|
||
10 years ago
|
}
|
||
|
|
||
|
type StateLog struct {
|
||
10 years ago
|
address common.Address
|
||
10 years ago
|
topics []common.Hash
|
||
10 years ago
|
data []byte
|
||
10 years ago
|
number uint64
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
func NewLog(address common.Address, topics []common.Hash, data []byte, number uint64) *StateLog {
|
||
10 years ago
|
return &StateLog{address, topics, data, number}
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
func (self *StateLog) Address() common.Address {
|
||
10 years ago
|
return self.address
|
||
|
}
|
||
|
|
||
10 years ago
|
func (self *StateLog) Topics() []common.Hash {
|
||
10 years ago
|
return self.topics
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
func (self *StateLog) Data() []byte {
|
||
|
return self.data
|
||
|
}
|
||
|
|
||
10 years ago
|
func (self *StateLog) Number() uint64 {
|
||
|
return self.number
|
||
|
}
|
||
|
|
||
10 years ago
|
/*
|
||
10 years ago
|
func NewLogFromValue(decoder *common.Value) *StateLog {
|
||
10 years ago
|
var extlog struct {
|
||
|
|
||
|
}
|
||
|
|
||
10 years ago
|
log := &StateLog{
|
||
|
address: decoder.Get(0).Bytes(),
|
||
|
data: decoder.Get(2).Bytes(),
|
||
10 years ago
|
}
|
||
|
|
||
|
it := decoder.Get(1).NewIterator()
|
||
|
for it.Next() {
|
||
10 years ago
|
log.topics = append(log.topics, it.Value().Bytes())
|
||
10 years ago
|
}
|
||
|
|
||
|
return log
|
||
|
}
|
||
10 years ago
|
*/
|
||
10 years ago
|
|
||
10 years ago
|
func (self *StateLog) EncodeRLP(w io.Writer) error {
|
||
|
return rlp.Encode(w, []interface{}{self.address, self.topics, self.data})
|
||
|
}
|
||
|
|
||
|
/*
|
||
10 years ago
|
func (self *StateLog) RlpData() interface{} {
|
||
10 years ago
|
return []interface{}{self.address, common.ByteSliceToInterface(self.topics), self.data}
|
||
10 years ago
|
}
|
||
10 years ago
|
*/
|
||
10 years ago
|
|
||
10 years ago
|
func (self *StateLog) String() string {
|
||
|
return fmt.Sprintf(`log: %x %x %x`, self.address, self.topics, self.data)
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
type Logs []Log
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
10 years ago
|
func (self Logs) RlpData() interface{} {
|
||
|
data := make([]interface{}, len(self))
|
||
|
for i, log := range self {
|
||
|
data[i] = log.RlpData()
|
||
|
}
|
||
|
|
||
|
return data
|
||
|
}
|
||
10 years ago
|
*/
|
||
10 years ago
|
|
||
10 years ago
|
func (self Logs) String() (ret string) {
|
||
10 years ago
|
for _, log := range self {
|
||
10 years ago
|
ret += fmt.Sprintf("%v", log)
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
|
return "[" + ret + "]"
|
||
10 years ago
|
}
|