-
Notifications
You must be signed in to change notification settings - Fork 179
/
results.go
42 lines (33 loc) · 1.84 KB
/
results.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
40
41
42
package operation
import (
"github.com/dgraph-io/badger/v2"
"github.com/onflow/flow-go/model/flow"
)
// InsertExecutionResult inserts an execution result by ID.
func InsertExecutionResult(result *flow.ExecutionResult) func(*badger.Txn) error {
return insert(makePrefix(codeExecutionResult, result.ID()), result)
}
// UpsertExecutionResult inserts an execution result by ID.
func BatchInsertExecutionResult(result *flow.ExecutionResult) func(batch *badger.WriteBatch) error {
return batchInsert(makePrefix(codeExecutionResult, result.ID()), result)
}
// RetrieveExecutionResult retrieves a transaction by fingerprint.
func RetrieveExecutionResult(resultID flow.Identifier, result *flow.ExecutionResult) func(*badger.Txn) error {
return retrieve(makePrefix(codeExecutionResult, resultID), result)
}
// IndexExecutionResult inserts an execution result ID keyed by block ID
func IndexExecutionResult(blockID flow.Identifier, resultID flow.Identifier) func(*badger.Txn) error {
return insert(makePrefix(codeIndexExecutionResultByBlock, blockID), resultID)
}
// ReindexExecutionResult updates mapping of an execution result ID keyed by block ID
func ReindexExecutionResult(blockID flow.Identifier, resultID flow.Identifier) func(*badger.Txn) error {
return update(makePrefix(codeIndexExecutionResultByBlock, blockID), resultID)
}
// BatchIndexExecutionResult inserts an execution result ID keyed by block ID into a batch
func BatchIndexExecutionResult(blockID flow.Identifier, resultID flow.Identifier) func(batch *badger.WriteBatch) error {
return batchInsert(makePrefix(codeIndexExecutionResultByBlock, blockID), resultID)
}
// LookupExecutionResult finds execution result ID by block
func LookupExecutionResult(blockID flow.Identifier, resultID *flow.Identifier) func(*badger.Txn) error {
return retrieve(makePrefix(codeIndexExecutionResultByBlock, blockID), resultID)
}