mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Change transaction index to uint
This commit is contained in:
parent
d797d250e8
commit
a6a9df1437
7 changed files with 17 additions and 14 deletions
|
|
@ -802,7 +802,7 @@ func SetReceiptsData(config *params.ChainConfig, block *types.Block, receipts ty
|
|||
// block location fields
|
||||
receipts[j].BlockHash = block.Hash()
|
||||
receipts[j].BlockNumber = block.Number()
|
||||
receipts[j].TransactionIndex = big.NewInt(int64(j))
|
||||
receipts[j].TransactionIndex = uint(j)
|
||||
|
||||
// The contract address can be derived from the transaction itself
|
||||
if transactions[j].To() == nil {
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ func ReadReceipts(db DatabaseReader, hash common.Hash, number uint64) types.Rece
|
|||
receipts[i] = (*types.Receipt)(receipt)
|
||||
receipts[i].BlockHash = hash
|
||||
receipts[i].BlockNumber = big.NewInt(0).SetUint64(number)
|
||||
receipts[i].TransactionIndex = big.NewInt(int64(i))
|
||||
receipts[i].TransactionIndex = uint(i)
|
||||
}
|
||||
return receipts
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// StateProcessor is a basic Processor, which takes care of transitioning
|
||||
|
|
@ -124,7 +123,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
|
|||
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
|
||||
receipt.BlockHash = header.Hash()
|
||||
receipt.BlockNumber = header.Number
|
||||
receipt.TransactionIndex = big.NewInt(int64(statedb.TxIndex()))
|
||||
receipt.TransactionIndex = uint(statedb.TxIndex())
|
||||
|
||||
return receipt, gas, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
|
|||
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
||||
BlockHash common.Hash `json:"blockHash,omitempty"`
|
||||
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
|
||||
TransactionIndex *hexutil.Big `json:"transactionIndex,omitempty"`
|
||||
TransactionIndex hexutil.Uint `json:"transactionIndex"`
|
||||
}
|
||||
var enc Receipt
|
||||
enc.PostState = r.PostState
|
||||
|
|
@ -39,7 +39,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
|
|||
enc.GasUsed = hexutil.Uint64(r.GasUsed)
|
||||
enc.BlockHash = r.BlockHash
|
||||
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
|
||||
enc.TransactionIndex = (*hexutil.Big)(r.TransactionIndex)
|
||||
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
|
|||
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
||||
BlockHash *common.Hash `json:"blockHash,omitempty"`
|
||||
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
|
||||
TransactionIndex *hexutil.Big `json:"transactionIndex,omitempty"`
|
||||
TransactionIndex *hexutil.Uint `json:"transactionIndex"`
|
||||
}
|
||||
var dec Receipt
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
|
|
@ -98,7 +98,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
|
|||
r.BlockNumber = (*big.Int)(dec.BlockNumber)
|
||||
}
|
||||
if dec.TransactionIndex != nil {
|
||||
r.TransactionIndex = (*big.Int)(dec.TransactionIndex)
|
||||
r.TransactionIndex = uint(*dec.TransactionIndex)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
var _ = (*txdataMarshaling)(nil)
|
||||
|
||||
// MarshalJSON marshals as JSON.
|
||||
func (t txdata) MarshalJSON() ([]byte, error) {
|
||||
type txdata struct {
|
||||
AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"`
|
||||
|
|
@ -40,6 +41,7 @@ func (t txdata) MarshalJSON() ([]byte, error) {
|
|||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals from JSON.
|
||||
func (t *txdata) UnmarshalJSON(input []byte) error {
|
||||
type txdata struct {
|
||||
AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"`
|
||||
|
|
|
|||
|
|
@ -45,22 +45,24 @@ const (
|
|||
|
||||
// Receipt represents the results of a transaction.
|
||||
type Receipt struct {
|
||||
// Consensus fields
|
||||
// Consensus fields: These fields are defined by the Yellow Paper
|
||||
PostState []byte `json:"root"`
|
||||
Status uint64 `json:"status"`
|
||||
CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"`
|
||||
Bloom Bloom `json:"logsBloom" gencodec:"required"`
|
||||
Logs []*Log `json:"logs" gencodec:"required"`
|
||||
|
||||
// Implementation fields (don't reorder!)
|
||||
// Implementation fields: These fields are added by geth when processing a transaction.
|
||||
// They are stored in the chain database.
|
||||
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
|
||||
// Inclusion information: These fields provide information about the inclusion of the
|
||||
// transaction corresponding to this receipt.
|
||||
BlockHash common.Hash `json:"blockHash,omitempty"`
|
||||
BlockNumber *big.Int `json:"blockNumber,omitempty"`
|
||||
TransactionIndex *big.Int `json:"transactionIndex,omitempty"`
|
||||
TransactionIndex uint `json:"transactionIndex"`
|
||||
}
|
||||
|
||||
type receiptMarshaling struct {
|
||||
|
|
@ -69,7 +71,7 @@ type receiptMarshaling struct {
|
|||
CumulativeGasUsed hexutil.Uint64
|
||||
GasUsed hexutil.Uint64
|
||||
BlockNumber *hexutil.Big
|
||||
TransactionIndex *hexutil.Big
|
||||
TransactionIndex hexutil.Uint
|
||||
}
|
||||
|
||||
// receiptRLP is the consensus encoding of a receipt.
|
||||
|
|
|
|||
|
|
@ -569,7 +569,7 @@ func (w *worker) resultLoop() {
|
|||
// add block location fields
|
||||
receipt.BlockHash = hash
|
||||
receipt.BlockNumber = block.Number()
|
||||
receipt.TransactionIndex = big.NewInt(int64(i))
|
||||
receipt.TransactionIndex = uint(i)
|
||||
|
||||
receipts[i] = new(types.Receipt)
|
||||
*receipts[i] = *receipt
|
||||
|
|
|
|||
Loading…
Reference in a new issue