ReadPrivateReceipt reads private receipt associated with specified transaction.
(txHash common.Hash, db database.Database)
| 62 | |
| 63 | // ReadPrivateReceipt reads private receipt associated with specified transaction. |
| 64 | func 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 | |
| 83 | func getPrivateReceiptKey(txHash common.Hash) common.Hash { |
| 84 | // Generate hash combining tx hash and private receipt prefix. |