-
Notifications
You must be signed in to change notification settings - Fork 179
/
transaction_results.go
41 lines (32 loc) · 1.4 KB
/
transaction_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
// (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
package operation
import (
"github.com/dgraph-io/badger/v2"
"github.com/onflow/flow-go/model/flow"
)
func InsertTransactionResult(blockID flow.Identifier, transactionResult *flow.TransactionResult) func(*badger.Txn) error {
return insert(makePrefix(codeTransactionResult, blockID, transactionResult.TransactionID), transactionResult)
}
func BatchInsertTransactionResult(blockID flow.Identifier, transactionResult *flow.TransactionResult) func(batch *badger.WriteBatch) error {
return batchInsert(makePrefix(codeTransactionResult, blockID, transactionResult.TransactionID), transactionResult)
}
func RetrieveTransactionResult(blockID flow.Identifier, transactionID flow.Identifier, transactionResult *flow.TransactionResult) func(*badger.Txn) error {
return retrieve(makePrefix(codeTransactionResult, blockID, transactionID), transactionResult)
}
func LookupTransactionResultsByBlockID(blockID flow.Identifier, txResults *[]flow.TransactionResult) func(*badger.Txn) error {
txErrIterFunc := func() (checkFunc, createFunc, handleFunc) {
check := func(_ []byte) bool {
return true
}
var val flow.TransactionResult
create := func() interface{} {
return &val
}
handle := func() error {
*txResults = append(*txResults, val)
return nil
}
return check, create, handle
}
return traverse(makePrefix(codeTransactionResult, blockID), txErrIterFunc)
}