github.com/immesys/bw2bc@v1.1.0/core/state/log.go (about) 1 // Copyright 2014 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package state 18 19 import ( 20 "fmt" 21 "io" 22 23 "github.com/ethereum/go-ethereum/common" 24 "github.com/ethereum/go-ethereum/rlp" 25 ) 26 27 type Log struct { 28 Address common.Address 29 Topics []common.Hash 30 Data []byte 31 Number uint64 32 33 TxHash common.Hash 34 TxIndex uint 35 BlockHash common.Hash 36 Index uint 37 } 38 39 func NewLog(address common.Address, topics []common.Hash, data []byte, number uint64) *Log { 40 return &Log{Address: address, Topics: topics, Data: data, Number: number} 41 } 42 43 func (self *Log) EncodeRLP(w io.Writer) error { 44 return rlp.Encode(w, []interface{}{self.Address, self.Topics, self.Data}) 45 } 46 47 func (self *Log) String() string { 48 return fmt.Sprintf(`log: %x %x %x %x %d %x %d`, self.Address, self.Topics, self.Data, self.TxHash, self.TxIndex, self.BlockHash, self.Index) 49 } 50 51 type Logs []*Log 52 53 type LogForStorage Log 54 55 func (self *LogForStorage) EncodeRLP(w io.Writer) error { 56 return rlp.Encode(w, []interface{}{ 57 self.Address, 58 self.Topics, 59 self.Data, 60 self.Number, 61 self.TxHash, 62 self.TxIndex, 63 self.BlockHash, 64 self.Index, 65 }) 66 }