@ -17,13 +17,11 @@
package types
package types
import (
import (
"io"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
)
)
//go:generate go run ../../rlp/rlpgen -type Log -out gen_log_rlp.go
//go:generate go run github.com/fjl/gencodec -type Log -field-override logMarshaling -out gen_log_json.go
//go:generate go run github.com/fjl/gencodec -type Log -field-override logMarshaling -out gen_log_json.go
// Log represents a contract log event. These events are generated by the LOG opcode and
// Log represents a contract log event. These events are generated by the LOG opcode and
@ -40,19 +38,19 @@ type Log struct {
// Derived fields. These fields are filled in by the node
// Derived fields. These fields are filled in by the node
// but not secured by consensus.
// but not secured by consensus.
// block in which the transaction was included
// block in which the transaction was included
BlockNumber uint64 ` json:"blockNumber" `
BlockNumber uint64 ` json:"blockNumber" rlp:"-" `
// hash of the transaction
// hash of the transaction
TxHash common . Hash ` json:"transactionHash" gencodec:"required" `
TxHash common . Hash ` json:"transactionHash" gencodec:"required" rlp:"-" `
// index of the transaction in the block
// index of the transaction in the block
TxIndex uint ` json:"transactionIndex" `
TxIndex uint ` json:"transactionIndex" rlp:"-" `
// hash of the block in which the transaction was included
// hash of the block in which the transaction was included
BlockHash common . Hash ` json:"blockHash" `
BlockHash common . Hash ` json:"blockHash" rlp:"-" `
// index of the log in the block
// index of the log in the block
Index uint ` json:"logIndex" `
Index uint ` json:"logIndex" rlp:"-" `
// The Removed field is true if this log was reverted due to a chain reorganisation.
// The Removed field is true if this log was reverted due to a chain reorganisation.
// You must pay attention to this field if you receive logs through a filter query.
// You must pay attention to this field if you receive logs through a filter query.
Removed bool ` json:"removed" `
Removed bool ` json:"removed" rlp:"-" `
}
}
type logMarshaling struct {
type logMarshaling struct {
@ -61,28 +59,3 @@ type logMarshaling struct {
TxIndex hexutil . Uint
TxIndex hexutil . Uint
Index hexutil . Uint
Index hexutil . Uint
}
}
//go:generate go run ../../rlp/rlpgen -type rlpLog -out gen_log_rlp.go
// rlpLog is used to RLP-encode both the consensus and storage formats.
type rlpLog struct {
Address common . Address
Topics [ ] common . Hash
Data [ ] byte
}
// EncodeRLP implements rlp.Encoder.
func ( l * Log ) EncodeRLP ( w io . Writer ) error {
rl := rlpLog { Address : l . Address , Topics : l . Topics , Data : l . Data }
return rlp . Encode ( w , & rl )
}
// DecodeRLP implements rlp.Decoder.
func ( l * Log ) DecodeRLP ( s * rlp . Stream ) error {
var dec rlpLog
err := s . Decode ( & dec )
if err == nil {
l . Address , l . Topics , l . Data = dec . Address , dec . Topics , dec . Data
}
return err
}