Merge pull request #1118 from ethcore/implementreceiptgasused
Implement receipt's gasUsed field
This commit is contained in:
commit
e952d62950
@ -580,14 +580,21 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
|
|||||||
let block_number = tx.block_number.clone();
|
let block_number = tx.block_number.clone();
|
||||||
let transaction_hash = tx.hash();
|
let transaction_hash = tx.hash();
|
||||||
let transaction_index = tx.transaction_index;
|
let transaction_index = tx.transaction_index;
|
||||||
|
let prior_gas_used = match tx.transaction_index {
|
||||||
|
0 => U256::zero(),
|
||||||
|
i => {
|
||||||
|
let prior_address = TransactionAddress { block_hash: address.block_hash, index: i - 1 };
|
||||||
|
let prior_receipt = self.chain.transaction_receipt(&prior_address).expect("Transaction receipt at `address` exists; `prior_address` has lower index in same block; qed");
|
||||||
|
prior_receipt.gas_used
|
||||||
|
}
|
||||||
|
};
|
||||||
Some(LocalizedReceipt {
|
Some(LocalizedReceipt {
|
||||||
transaction_hash: tx.hash(),
|
transaction_hash: tx.hash(),
|
||||||
transaction_index: tx.transaction_index,
|
transaction_index: tx.transaction_index,
|
||||||
block_hash: tx.block_hash,
|
block_hash: tx.block_hash,
|
||||||
block_number: tx.block_number,
|
block_number: tx.block_number,
|
||||||
// TODO: to fix this, query all previous transaction receipts and retrieve their gas usage
|
|
||||||
cumulative_gas_used: receipt.gas_used,
|
cumulative_gas_used: receipt.gas_used,
|
||||||
gas_used: receipt.gas_used,
|
gas_used: receipt.gas_used - prior_gas_used,
|
||||||
contract_address: match tx.action {
|
contract_address: match tx.action {
|
||||||
Action::Call(_) => None,
|
Action::Call(_) => None,
|
||||||
Action::Create => Some(contract_address(&tx.sender().unwrap(), &tx.nonce))
|
Action::Create => Some(contract_address(&tx.sender().unwrap(), &tx.nonce))
|
||||||
|
@ -91,9 +91,9 @@ pub struct LocalizedReceipt {
|
|||||||
pub block_hash: H256,
|
pub block_hash: H256,
|
||||||
/// Block number.
|
/// Block number.
|
||||||
pub block_number: BlockNumber,
|
pub block_number: BlockNumber,
|
||||||
/// Cumulative gas used.
|
/// The total gas used in the block following execution of the transaction.
|
||||||
pub cumulative_gas_used: U256,
|
pub cumulative_gas_used: U256,
|
||||||
/// Gas used.
|
/// The gas used in the execution of the transaction. Note the difference of meaning to `Receipt::gas_used`.
|
||||||
pub gas_used: U256,
|
pub gas_used: U256,
|
||||||
/// Contract address.
|
/// Contract address.
|
||||||
pub contract_address: Option<Address>,
|
pub contract_address: Option<Address>,
|
||||||
|
@ -117,10 +117,10 @@ Sealing/Mining Options:
|
|||||||
|
|
||||||
Footprint Options:
|
Footprint Options:
|
||||||
--tracing BOOL Indicates if full transaction tracing should be
|
--tracing BOOL Indicates if full transaction tracing should be
|
||||||
enabled. Works only if client had been fully synced with
|
enabled. Works only if client had been fully synced
|
||||||
tracing enabled. BOOL may be one of auto, on, off.
|
with tracing enabled. BOOL may be one of auto, on,
|
||||||
auto uses last used value of this option (off if it does
|
off. auto uses last used value of this option (off
|
||||||
not exist) [default: auto].
|
if it does not exist) [default: auto].
|
||||||
--pruning METHOD Configure pruning of the state/storage trie. METHOD
|
--pruning METHOD Configure pruning of the state/storage trie. METHOD
|
||||||
may be one of auto, archive, fast, basic, light:
|
may be one of auto, archive, fast, basic, light:
|
||||||
archive - keep all state trie data. No pruning.
|
archive - keep all state trie data. No pruning.
|
||||||
|
Loading…
Reference in New Issue
Block a user