MCPcopy Create free account
hub / github.com/CPChain/chain / ReadPrivateReceipt

Function ReadPrivateReceipt

core/private_database.go:64–81  ·  view source on GitHub ↗

ReadPrivateReceipt reads private receipt associated with specified transaction.

(txHash common.Hash, db database.Database)

Source from the content-addressed store, hash-verified

62
63// ReadPrivateReceipt reads private receipt associated with specified transaction.
64func ReadPrivateReceipt(txHash common.Hash, db database.Database) (*types.Receipt, error) {
65 hash := getPrivateReceiptKey(txHash)
66 // Read private receipt data
67 data, err := db.Get(hash.Bytes())
68 if err != nil {
69 return nil, err
70 }
71 // Decode receipt
72 storageReceipt := types.ReceiptForStorage{}
73 rlp.DecodeBytes(data, &storageReceipt)
74 receipt := (*types.Receipt)(&storageReceipt)
75 // TODO: workaround for a suspected bug on RLP of Receipt.
76 if len(receipt.PostState) != 0 {
77 receipt.Status = types.ReceiptStatusSuccessful
78 }
79
80 return (*types.Receipt)(&storageReceipt), nil
81}
82
83func getPrivateReceiptKey(txHash common.Hash) common.Hash {
84 // Generate hash combining tx hash and private receipt prefix.

Callers 1

TestReadPrivateReceiptFunction · 0.85

Calls 3

getPrivateReceiptKeyFunction · 0.85
GetMethod · 0.65
BytesMethod · 0.65

Tested by 1

TestReadPrivateReceiptFunction · 0.68