github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/badger/operation/payload.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  func InsertSeal(sealID flow.Identifier, seal *flow.Seal) func(*badger.Txn) error {
    10  	return insert(makePrefix(codeSeal, sealID), seal)
    11  }
    12  
    13  func RetrieveSeal(sealID flow.Identifier, seal *flow.Seal) func(*badger.Txn) error {
    14  	return retrieve(makePrefix(codeSeal, sealID), seal)
    15  }
    16  
    17  func IndexPayloadSeals(blockID flow.Identifier, sealIDs []flow.Identifier) func(*badger.Txn) error {
    18  	return insert(makePrefix(codePayloadSeals, blockID), sealIDs)
    19  }
    20  
    21  func LookupPayloadSeals(blockID flow.Identifier, sealIDs *[]flow.Identifier) func(*badger.Txn) error {
    22  	return retrieve(makePrefix(codePayloadSeals, blockID), sealIDs)
    23  }
    24  
    25  func IndexPayloadReceipts(blockID flow.Identifier, receiptIDs []flow.Identifier) func(*badger.Txn) error {
    26  	return insert(makePrefix(codePayloadReceipts, blockID), receiptIDs)
    27  }
    28  
    29  func IndexPayloadResults(blockID flow.Identifier, resultIDs []flow.Identifier) func(*badger.Txn) error {
    30  	return insert(makePrefix(codePayloadResults, blockID), resultIDs)
    31  }
    32  
    33  func IndexPayloadProtocolStateID(blockID flow.Identifier, stateID flow.Identifier) func(*badger.Txn) error {
    34  	return insert(makePrefix(codePayloadProtocolStateID, blockID), stateID)
    35  }
    36  
    37  func LookupPayloadProtocolStateID(blockID flow.Identifier, stateID *flow.Identifier) func(*badger.Txn) error {
    38  	return retrieve(makePrefix(codePayloadProtocolStateID, blockID), stateID)
    39  }
    40  
    41  func LookupPayloadReceipts(blockID flow.Identifier, receiptIDs *[]flow.Identifier) func(*badger.Txn) error {
    42  	return retrieve(makePrefix(codePayloadReceipts, blockID), receiptIDs)
    43  }
    44  
    45  func LookupPayloadResults(blockID flow.Identifier, resultIDs *[]flow.Identifier) func(*badger.Txn) error {
    46  	return retrieve(makePrefix(codePayloadResults, blockID), resultIDs)
    47  }
    48  
    49  // IndexLatestSealAtBlock persists the highest seal that was included in the fork up to (and including) blockID.
    50  // In most cases, it is the highest seal included in this block's payload. However, if there are no
    51  // seals in this block, sealID should reference the highest seal in blockID's ancestor.
    52  func IndexLatestSealAtBlock(blockID flow.Identifier, sealID flow.Identifier) func(*badger.Txn) error {
    53  	return insert(makePrefix(codeBlockIDToLatestSealID, blockID), sealID)
    54  }
    55  
    56  // LookupLatestSealAtBlock finds the highest seal that was included in the fork up to (and including) blockID.
    57  // In most cases, it is the highest seal included in this block's payload. However, if there are no
    58  // seals in this block, sealID should reference the highest seal in blockID's ancestor.
    59  func LookupLatestSealAtBlock(blockID flow.Identifier, sealID *flow.Identifier) func(*badger.Txn) error {
    60  	return retrieve(makePrefix(codeBlockIDToLatestSealID, blockID), &sealID)
    61  }
    62  
    63  // IndexFinalizedSealByBlockID indexes the _finalized_ seal by the sealed block ID.
    64  // Example: A <- B <- C(SealA)
    65  // when block C is finalized, we create the index `A.ID->SealA.ID`
    66  func IndexFinalizedSealByBlockID(sealedBlockID flow.Identifier, sealID flow.Identifier) func(*badger.Txn) error {
    67  	return insert(makePrefix(codeBlockIDToFinalizedSeal, sealedBlockID), sealID)
    68  }
    69  
    70  // LookupBySealedBlockID finds the seal for the given sealed block ID.
    71  func LookupBySealedBlockID(sealedBlockID flow.Identifier, sealID *flow.Identifier) func(*badger.Txn) error {
    72  	return retrieve(makePrefix(codeBlockIDToFinalizedSeal, sealedBlockID), &sealID)
    73  }
    74  
    75  func InsertExecutionForkEvidence(conflictingSeals []*flow.IncorporatedResultSeal) func(*badger.Txn) error {
    76  	return insert(makePrefix(codeExecutionFork), conflictingSeals)
    77  }
    78  
    79  func RemoveExecutionForkEvidence() func(*badger.Txn) error {
    80  	return remove(makePrefix(codeExecutionFork))
    81  }
    82  
    83  func RetrieveExecutionForkEvidence(conflictingSeals *[]*flow.IncorporatedResultSeal) func(*badger.Txn) error {
    84  	return retrieve(makePrefix(codeExecutionFork), conflictingSeals)
    85  }