aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 02:59:12 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-07 03:18:24 +0800
commit666a7dda369e9a30715f560c8f72b81735a347fc (patch)
tree62011e66bba6335bf4c7693d796c4757395e248e /core
parent4c30f0f9ac33e02908c6848744dafff9031b86f3 (diff)
downloadgo-tangerine-666a7dda369e9a30715f560c8f72b81735a347fc.tar
go-tangerine-666a7dda369e9a30715f560c8f72b81735a347fc.tar.gz
go-tangerine-666a7dda369e9a30715f560c8f72b81735a347fc.tar.bz2
go-tangerine-666a7dda369e9a30715f560c8f72b81735a347fc.tar.lz
go-tangerine-666a7dda369e9a30715f560c8f72b81735a347fc.tar.xz
go-tangerine-666a7dda369e9a30715f560c8f72b81735a347fc.tar.zst
go-tangerine-666a7dda369e9a30715f560c8f72b81735a347fc.zip
core, eth, rpc: proper gas used. Closes #1417
Added some additional backward compatibility code for old receipts
Diffstat (limited to 'core')
-rw-r--r--core/block_processor.go1
-rw-r--r--core/transaction_util.go2
-rw-r--r--core/types/receipt.go6
3 files changed, 6 insertions, 3 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 9a7478381..362036445 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -82,6 +82,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
usedGas.Add(usedGas, gas)
receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas)
receipt.TxHash = tx.Hash()
+ receipt.GasUsed = new(big.Int).Set(gas)
if MessageCreatesContract(tx) {
from, _ := tx.From()
receipt.ContractAddress = crypto.CreateAddress(from, tx.Nonce())
diff --git a/core/transaction_util.go b/core/transaction_util.go
index cb5d6c7f7..7d432848a 100644
--- a/core/transaction_util.go
+++ b/core/transaction_util.go
@@ -64,7 +64,7 @@ func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt {
var receipt types.Receipt
err := rlp.DecodeBytes(data, &receipt)
if err != nil {
- glog.V(logger.Error).Infoln("GetReceipt err:", err)
+ glog.V(logger.Core).Infoln("GetReceipt err:", err)
}
return &receipt
}
diff --git a/core/types/receipt.go b/core/types/receipt.go
index ab52c6e60..aff29f565 100644
--- a/core/types/receipt.go
+++ b/core/types/receipt.go
@@ -18,6 +18,7 @@ type Receipt struct {
TxHash common.Hash
ContractAddress common.Address
logs state.Logs
+ GasUsed *big.Int
}
func NewReceipt(root []byte, cumalativeGasUsed *big.Int) *Receipt {
@@ -44,11 +45,12 @@ func (self *Receipt) DecodeRLP(s *rlp.Stream) error {
TxHash common.Hash
ContractAddress common.Address
Logs state.Logs
+ GasUsed *big.Int
}
if err := s.Decode(&r); err != nil {
return err
}
- self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, self.logs = r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, r.Logs
+ self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, self.logs, self.GasUsed = r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, r.Logs, r.GasUsed
return nil
}
@@ -60,7 +62,7 @@ func (self *ReceiptForStorage) EncodeRLP(w io.Writer) error {
for i, log := range self.logs {
storageLogs[i] = (*state.LogForStorage)(log)
}
- return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, storageLogs})
+ return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, storageLogs, self.GasUsed})
}
func (self *Receipt) RlpEncode() []byte {