-
Notifications
You must be signed in to change notification settings - Fork 179
/
commits.go
30 lines (24 loc) · 1.16 KB
/
commits.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
// (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
package operation
import (
"github.com/dgraph-io/badger/v2"
"github.com/onflow/flow-go/model/flow"
)
// IndexStateCommitment indexes a state commitment.
//
// State commitments are keyed by the block whose execution results in the state with the given commit.
func IndexStateCommitment(blockID flow.Identifier, commit flow.StateCommitment) func(*badger.Txn) error {
return insert(makePrefix(codeCommit, blockID), commit)
}
// BatchIndexStateCommitment indexes a state commitment into a batch
//
// State commitments are keyed by the block whose execution results in the state with the given commit.
func BatchIndexStateCommitment(blockID flow.Identifier, commit flow.StateCommitment) func(batch *badger.WriteBatch) error {
return batchInsert(makePrefix(codeCommit, blockID), commit)
}
// LookupStateCommitment gets a state commitment keyed by block ID
//
// State commitments are keyed by the block whose execution results in the state with the given commit.
func LookupStateCommitment(blockID flow.Identifier, commit *flow.StateCommitment) func(*badger.Txn) error {
return retrieve(makePrefix(codeCommit, blockID), commit)
}