mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
common: add BlockNumber to transaction receipt
This commit is contained in:
parent
9e4f96a1a6
commit
9dbf725ced
2 changed files with 12 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
|
|||
CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"`
|
||||
Bloom Bloom `json:"logsBloom" gencodec:"required"`
|
||||
Logs []*Log `json:"logs" gencodec:"required"`
|
||||
BlockNumber hexutil.Uint64 `json:"blockNumber" gencodec:"required"`
|
||||
TxHash common.Hash `json:"transactionHash" gencodec:"required"`
|
||||
ContractAddress common.Address `json:"contractAddress"`
|
||||
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
||||
|
|
@ -30,6 +31,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
|
|||
enc.CumulativeGasUsed = hexutil.Uint64(r.CumulativeGasUsed)
|
||||
enc.Bloom = r.Bloom
|
||||
enc.Logs = r.Logs
|
||||
enc.BlockNumber = hexutil.Uint64(r.BlockNumber)
|
||||
enc.TxHash = r.TxHash
|
||||
enc.ContractAddress = r.ContractAddress
|
||||
enc.GasUsed = hexutil.Uint64(r.GasUsed)
|
||||
|
|
@ -44,6 +46,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
|
|||
CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"`
|
||||
Bloom *Bloom `json:"logsBloom" gencodec:"required"`
|
||||
Logs []*Log `json:"logs" gencodec:"required"`
|
||||
BlockNumber *hexutil.Uint64 `json:"blockNumber" gencodec:"required"`
|
||||
TxHash *common.Hash `json:"transactionHash" gencodec:"required"`
|
||||
ContractAddress *common.Address `json:"contractAddress"`
|
||||
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
||||
|
|
@ -70,6 +73,10 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
|
|||
return errors.New("missing required field 'logs' for Receipt")
|
||||
}
|
||||
r.Logs = dec.Logs
|
||||
if dec.BlockNumber == nil {
|
||||
return errors.New("missing required field 'blockNumber' for Receipt")
|
||||
}
|
||||
r.BlockNumber = uint64(*dec.BlockNumber)
|
||||
if dec.TxHash == nil {
|
||||
return errors.New("missing required field 'transactionHash' for Receipt")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ type Receipt struct {
|
|||
CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"`
|
||||
Bloom Bloom `json:"logsBloom" gencodec:"required"`
|
||||
Logs []*Log `json:"logs" gencodec:"required"`
|
||||
BlockNumber uint64 `json:"blockNumber" gencodec:"required"`
|
||||
|
||||
// Implementation fields (don't reorder!)
|
||||
TxHash common.Hash `json:"transactionHash" gencodec:"required"`
|
||||
|
|
@ -61,6 +62,7 @@ type receiptMarshaling struct {
|
|||
PostState hexutil.Bytes
|
||||
Status hexutil.Uint64
|
||||
CumulativeGasUsed hexutil.Uint64
|
||||
BlockNumber hexutil.Uint64
|
||||
GasUsed hexutil.Uint64
|
||||
}
|
||||
|
||||
|
|
@ -70,6 +72,7 @@ type receiptRLP struct {
|
|||
CumulativeGasUsed uint64
|
||||
Bloom Bloom
|
||||
Logs []*Log
|
||||
BlockNumber uint64
|
||||
}
|
||||
|
||||
type receiptStorageRLP struct {
|
||||
|
|
@ -79,6 +82,7 @@ type receiptStorageRLP struct {
|
|||
TxHash common.Hash
|
||||
ContractAddress common.Address
|
||||
Logs []*LogForStorage
|
||||
BlockNumber uint64
|
||||
GasUsed uint64
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +100,7 @@ func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt {
|
|||
// EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt
|
||||
// into an RLP stream. If no post state is present, byzantium fork is assumed.
|
||||
func (r *Receipt) EncodeRLP(w io.Writer) error {
|
||||
return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs})
|
||||
return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs, r.BlockNumber})
|
||||
}
|
||||
|
||||
// DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt
|
||||
|
|
|
|||
Loading…
Reference in a new issue