From 93adf001dcbb9244922cff67e50db29bd5b1f581 Mon Sep 17 00:00:00 2001 From: Jonny Huxtable Date: Tue, 28 May 2019 14:24:32 +0100 Subject: [PATCH 1/2] Remove required logIndex and transactionIndex for light client support --- core/store/models/eth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 core/store/models/eth.go diff --git a/core/store/models/eth.go b/core/store/models/eth.go old mode 100644 new mode 100755 index 3b577e3295f..26dad9ff046 --- a/core/store/models/eth.go +++ b/core/store/models/eth.go @@ -36,11 +36,11 @@ type Log struct { // hash of the transaction TxHash common.Hash `json:"transactionHash"` // index of the transaction in the block - TxIndex uint `json:"transactionIndex" gencodec:"required"` + TxIndex uint `json:"transactionIndex"` // hash of the block in which the transaction was included BlockHash common.Hash `json:"blockHash"` // index of the log in the receipt - Index uint `json:"logIndex" gencodec:"required"` + Index uint `json:"logIndex"` // 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. From 2083f7f6eb0e229920e5f4e3a1333f8b9cd8b376 Mon Sep 17 00:00:00 2001 From: Jonny Huxtable Date: Tue, 28 May 2019 14:52:48 +0100 Subject: [PATCH 2/2] Remove the required fields and nil checks from gencodec log file --- core/store/models/gen_log_json.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) mode change 100644 => 100755 core/store/models/gen_log_json.go diff --git a/core/store/models/gen_log_json.go b/core/store/models/gen_log_json.go old mode 100644 new mode 100755 index 7781c3d0dba..cf6c6647dbf --- a/core/store/models/gen_log_json.go +++ b/core/store/models/gen_log_json.go @@ -20,9 +20,9 @@ func (l Log) MarshalJSON() ([]byte, error) { Data hexutil.Bytes `json:"data" gencodec:"required"` BlockNumber hexutil.Uint64 `json:"blockNumber"` TxHash common.Hash `json:"transactionHash"` - TxIndex hexutil.Uint `json:"transactionIndex" gencodec:"required"` + TxIndex hexutil.Uint `json:"transactionIndex"` BlockHash common.Hash `json:"blockHash"` - Index hexutil.Uint `json:"logIndex" gencodec:"required"` + Index hexutil.Uint `json:"logIndex"` Removed bool `json:"removed"` } var enc Log @@ -46,9 +46,9 @@ func (l *Log) UnmarshalJSON(input []byte) error { Data *hexutil.Bytes `json:"data" gencodec:"required"` BlockNumber *hexutil.Uint64 `json:"blockNumber"` TxHash *common.Hash `json:"transactionHash"` - TxIndex *hexutil.Uint `json:"transactionIndex" gencodec:"required"` + TxIndex *hexutil.Uint `json:"transactionIndex"` BlockHash *common.Hash `json:"blockHash"` - Index *hexutil.Uint `json:"logIndex" gencodec:"required"` + Index *hexutil.Uint `json:"logIndex"` Removed *bool `json:"removed"` } var dec Log @@ -73,17 +73,15 @@ func (l *Log) UnmarshalJSON(input []byte) error { if dec.TxHash != nil { l.TxHash = *dec.TxHash } - if dec.TxIndex == nil { - return errors.New("missing required field 'transactionIndex' for Log") + if dec.TxIndex != nil { + l.TxIndex = uint(*dec.TxIndex) } - l.TxIndex = uint(*dec.TxIndex) if dec.BlockHash != nil { l.BlockHash = *dec.BlockHash } - if dec.Index == nil { - return errors.New("missing required field 'logIndex' for Log") + if dec.Index != nil { + l.Index = uint(*dec.Index) } - l.Index = uint(*dec.Index) if dec.Removed != nil { l.Removed = *dec.Removed }