log.go 860 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package state
  2. import (
  3. "fmt"
  4. "io"
  5. "github.com/ethereum/go-ethereum/common"
  6. "github.com/ethereum/go-ethereum/rlp"
  7. )
  8. type Log struct {
  9. Address common.Address
  10. Topics []common.Hash
  11. Data []byte
  12. Number uint64
  13. TxHash common.Hash
  14. TxIndex uint
  15. BlockHash common.Hash
  16. Index uint
  17. }
  18. func NewLog(address common.Address, topics []common.Hash, data []byte, number uint64) *Log {
  19. return &Log{Address: address, Topics: topics, Data: data, Number: number}
  20. }
  21. func (self *Log) EncodeRLP(w io.Writer) error {
  22. return rlp.Encode(w, []interface{}{self.Address, self.Topics, self.Data})
  23. }
  24. func (self *Log) String() string {
  25. return fmt.Sprintf(`log: %x %x %x`, self.Address, self.Topics, self.Data)
  26. }
  27. type Logs []*Log
  28. func (self Logs) String() (ret string) {
  29. for _, log := range self {
  30. ret += fmt.Sprintf("%v", log)
  31. }
  32. return "[" + ret + "]"
  33. }