提交 481b2212 编写于 作者: T Taylor Gerring

Decode full receipt storage

上级 80eb8f46
...@@ -54,6 +54,21 @@ func PutReceipts(db common.Database, receipts types.Receipts) error { ...@@ -54,6 +54,21 @@ func PutReceipts(db common.Database, receipts types.Receipts) error {
return nil return nil
} }
// GetReceipt returns a receipt by hash
func GetFullReceipt(db common.Database, txHash common.Hash) *types.ReceiptForStorage {
data, _ := db.Get(append(receiptsPre, txHash[:]...))
if len(data) == 0 {
return nil
}
var receipt types.ReceiptForStorage
err := rlp.DecodeBytes(data, &receipt)
if err != nil {
glog.V(logger.Error).Infoln("GetReceipt err:", err)
}
return &receipt
}
// GetReceipt returns a receipt by hash // GetReceipt returns a receipt by hash
func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt { func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt {
data, _ := db.Get(append(receiptsPre, txHash[:]...)) data, _ := db.Get(append(receiptsPre, txHash[:]...))
......
...@@ -413,15 +413,17 @@ type ReceiptRes struct { ...@@ -413,15 +413,17 @@ type ReceiptRes struct {
Logs *[]interface{} `json:logs` Logs *[]interface{} `json:logs`
} }
func NewReceiptRes(rec *types.Receipt) *ReceiptRes { func NewReceiptRes(rec *types.ReceiptForStorage) *ReceiptRes {
if rec == nil { if rec == nil {
return nil return nil
} }
var v = new(ReceiptRes) var v = new(ReceiptRes)
// TODO fill out rest of object // TODO fill out rest of object
// ContractAddress is all 0 when not a creation tx
v.ContractAddress = newHexData(rec.ContractAddress)
v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed) v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed)
v.TransactionHash = newHexData(rec.TxHash)
return v return v
} }
......
...@@ -368,8 +368,8 @@ func (self *XEth) GetBlockReceipts(bhash common.Hash) types.Receipts { ...@@ -368,8 +368,8 @@ func (self *XEth) GetBlockReceipts(bhash common.Hash) types.Receipts {
return self.backend.BlockProcessor().GetBlockReceipts(bhash) return self.backend.BlockProcessor().GetBlockReceipts(bhash)
} }
func (self *XEth) GetTxReceipt(txhash common.Hash) *types.Receipt { func (self *XEth) GetTxReceipt(txhash common.Hash) *types.ReceiptForStorage {
return core.GetReceipt(self.backend.ExtraDb(), txhash) return core.GetFullReceipt(self.backend.ExtraDb(), txhash)
} }
func (self *XEth) GasLimit() *big.Int { func (self *XEth) GasLimit() *big.Int {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册