-
Notifications
You must be signed in to change notification settings - Fork 175
/
receipts.go
39 lines (31 loc) · 1.46 KB
/
receipts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package operation
import (
"github.com/dgraph-io/badger/v2"
"github.com/onflow/flow-go/model/flow"
)
// InsertExecutionReceiptMeta inserts an execution receipt meta by ID.
func InsertExecutionReceiptMeta(receiptID flow.Identifier, meta *flow.ExecutionReceiptMeta) func(*badger.Txn) error {
return insert(makePrefix(codeExecutionReceiptMeta, receiptID), meta)
}
// RetrieveExecutionReceipt retrieves a execution receipt meta by ID.
func RetrieveExecutionReceiptMeta(receiptID flow.Identifier, meta *flow.ExecutionReceiptMeta) func(*badger.Txn) error {
return retrieve(makePrefix(codeExecutionReceiptMeta, receiptID), meta)
}
// IndexExecutionReceipt inserts an execution receipt ID keyed by block ID
func IndexExecutionReceipt(blockID flow.Identifier, receiptID flow.Identifier) func(*badger.Txn) error {
return insert(makePrefix(codeBlockExecutionReceipt, blockID), receiptID)
}
// LookupExecutionReceipt finds execution receipt ID by block
func LookupExecutionReceipt(blockID flow.Identifier, receiptID *flow.Identifier) func(*badger.Txn) error {
return retrieve(makePrefix(codeBlockExecutionReceipt, blockID), receiptID)
}
func RemoveExecutionReceipt(blockID flow.Identifier, receipt *flow.ExecutionReceipt) func(*badger.Txn) error {
return func(txn *badger.Txn) error {
receiptID := receipt.ID()
err := remove(makePrefix(codeExecutionReceiptMeta, receiptID))(txn)
if err != nil {
return err
}
return remove(makePrefix(codeBlockExecutionReceipt, blockID))(txn)
}
}