Skip to content

Commit

Permalink
types, rawdb: add block location fields to receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
bmperrea committed Oct 15, 2018
1 parent 2e98631 commit 444dd6f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func ReadReceipts(db DatabaseReader, hash common.Hash, number uint64) types.Rece
if len(data) == 0 {
return nil
}
// Convert the revceipts from their storage form to their internal representation
// Convert the receipts from their storage form to their internal representation
storageReceipts := []*types.ReceiptForStorage{}
if err := rlp.DecodeBytes(data, &storageReceipts); err != nil {
log.Error("Invalid receipt array RLP", "hash", hash, "err", err)
Expand All @@ -287,6 +287,9 @@ func ReadReceipts(db DatabaseReader, hash common.Hash, number uint64) types.Rece
receipts := make(types.Receipts, len(storageReceipts))
for i, receipt := range storageReceipts {
receipts[i] = (*types.Receipt)(receipt)
receipts[i].BlockHash = hash
receipts[i].BlockNumber = big.NewInt(0).SetUint64(number)
receipts[i].TransactionIndex = big.NewInt(int64(i))
}
return receipts
}
Expand Down
19 changes: 19 additions & 0 deletions core/types/gen_receipt_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"io"
"math/big"
"unsafe"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -55,13 +56,20 @@ type Receipt struct {
TxHash common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress common.Address `json:"contractAddress"`
GasUsed uint64 `json:"gasUsed" gencodec:"required"`

// Block location fields - not part of the rlp
BlockHash common.Hash `json:"blockHash,omitempty"`
BlockNumber *big.Int `json:"blockNumber,omitempty"`
TransactionIndex *big.Int `json:"transactionIndex,omitempty"`
}

type receiptMarshaling struct {
PostState hexutil.Bytes
Status hexutil.Uint64
CumulativeGasUsed hexutil.Uint64
GasUsed hexutil.Uint64
BlockNumber *hexutil.Big
TransactionIndex *hexutil.Big
}

// receiptRLP is the consensus encoding of a receipt.
Expand Down

0 comments on commit 444dd6f

Please sign in to comment.