log.go 860 Bytes
Newer Older
obscuren's avatar
obscuren committed
1
package state
obscuren's avatar
obscuren committed
2

obscuren's avatar
obscuren committed
3 4
import (
	"fmt"
obscuren's avatar
obscuren committed
5
	"io"
obscuren's avatar
obscuren committed
6

obscuren's avatar
obscuren committed
7
	"github.com/ethereum/go-ethereum/common"
obscuren's avatar
obscuren committed
8
	"github.com/ethereum/go-ethereum/rlp"
obscuren's avatar
obscuren committed
9
)
obscuren's avatar
obscuren committed
10

11 12 13 14 15
type Log struct {
	Address common.Address
	Topics  []common.Hash
	Data    []byte
	Number  uint64
obscuren's avatar
obscuren committed
16

17 18 19 20
	TxHash    common.Hash
	TxIndex   uint
	BlockHash common.Hash
	Index     uint
obscuren's avatar
obscuren committed
21 22
}

23 24
func NewLog(address common.Address, topics []common.Hash, data []byte, number uint64) *Log {
	return &Log{Address: address, Topics: topics, Data: data, Number: number}
obscuren's avatar
obscuren committed
25 26
}

27 28
func (self *Log) EncodeRLP(w io.Writer) error {
	return rlp.Encode(w, []interface{}{self.Address, self.Topics, self.Data})
obscuren's avatar
obscuren committed
29 30
}

31 32
func (self *Log) String() string {
	return fmt.Sprintf(`log: %x %x %x`, self.Address, self.Topics, self.Data)
obscuren's avatar
obscuren committed
33 34
}

35
type Logs []*Log
obscuren's avatar
obscuren committed
36

obscuren's avatar
obscuren committed
37
func (self Logs) String() (ret string) {
obscuren's avatar
obscuren committed
38
	for _, log := range self {
obscuren's avatar
obscuren committed
39
		ret += fmt.Sprintf("%v", log)
obscuren's avatar
obscuren committed
40
	}
obscuren's avatar
obscuren committed
41 42

	return "[" + ret + "]"
obscuren's avatar
obscuren committed
43
}