github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/badger/operation/approvals.go (about)

     1  package operation
     2  
     3  import (
     4  	"github.com/dgraph-io/badger/v2"
     5  
     6  	"github.com/onflow/flow-go/model/flow"
     7  )
     8  
     9  // InsertResultApproval inserts a ResultApproval by ID.
    10  func InsertResultApproval(approval *flow.ResultApproval) func(*badger.Txn) error {
    11  	return insert(makePrefix(codeResultApproval, approval.ID()), approval)
    12  }
    13  
    14  // RetrieveResultApproval retrieves an approval by ID.
    15  func RetrieveResultApproval(approvalID flow.Identifier, approval *flow.ResultApproval) func(*badger.Txn) error {
    16  	return retrieve(makePrefix(codeResultApproval, approvalID), approval)
    17  }
    18  
    19  // IndexResultApproval inserts a ResultApproval ID keyed by ExecutionResult ID
    20  // and chunk index. If a value for this key exists, a storage.ErrAlreadyExists
    21  // error is returned. This operation is only used by the ResultApprovals store,
    22  // which is only used within a Verification node, where it is assumed that there
    23  // is only one approval per chunk.
    24  func IndexResultApproval(resultID flow.Identifier, chunkIndex uint64, approvalID flow.Identifier) func(*badger.Txn) error {
    25  	return insert(makePrefix(codeIndexResultApprovalByChunk, resultID, chunkIndex), approvalID)
    26  }
    27  
    28  // LookupResultApproval finds a ResultApproval by result ID and chunk index.
    29  func LookupResultApproval(resultID flow.Identifier, chunkIndex uint64, approvalID *flow.Identifier) func(*badger.Txn) error {
    30  	return retrieve(makePrefix(codeIndexResultApprovalByChunk, resultID, chunkIndex), approvalID)
    31  }