github.com/koko1123/flow-go-1@v0.29.6/storage/badger/operation/seals.go (about) 1 package operation 2 3 import ( 4 "github.com/dgraph-io/badger/v3" 5 6 "github.com/koko1123/flow-go-1/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 LookupPayloadReceipts(blockID flow.Identifier, receiptIDs *[]flow.Identifier) func(*badger.Txn) error { 34 return retrieve(makePrefix(codePayloadReceipts, blockID), receiptIDs) 35 } 36 37 func LookupPayloadResults(blockID flow.Identifier, resultIDs *[]flow.Identifier) func(*badger.Txn) error { 38 return retrieve(makePrefix(codePayloadResults, blockID), resultIDs) 39 } 40 41 // IndexLatestSealAtBlock persists the highest seal that was included in the fork up to (and including) blockID. 42 // In most cases, it is the highest seal included in this block's payload. However, if there are no 43 // seals in this block, sealID should reference the highest seal in blockID's ancestor. 44 func IndexLatestSealAtBlock(blockID flow.Identifier, sealID flow.Identifier) func(*badger.Txn) error { 45 return insert(makePrefix(codeBlockIDToLatestSealID, blockID), sealID) 46 } 47 48 // LookupLatestSealAtBlock finds the highest seal that was included in the fork up to (and including) blockID. 49 // In most cases, it is the highest seal included in this block's payload. However, if there are no 50 // seals in this block, sealID should reference the highest seal in blockID's ancestor. 51 func LookupLatestSealAtBlock(blockID flow.Identifier, sealID *flow.Identifier) func(*badger.Txn) error { 52 return retrieve(makePrefix(codeBlockIDToLatestSealID, blockID), &sealID) 53 } 54 55 // IndexFinalizedSealByBlockID indexes the _finalized_ seal by the sealed block ID. 56 // Example: A <- B <- C(SealA) 57 // when block C is finalized, we create the index `A.ID->SealA.ID` 58 func IndexFinalizedSealByBlockID(sealedBlockID flow.Identifier, sealID flow.Identifier) func(*badger.Txn) error { 59 return insert(makePrefix(codeBlockIDToFinalizedSeal, sealedBlockID), sealID) 60 } 61 62 // LookupBySealedBlockID finds the seal for the given sealed block ID. 63 func LookupBySealedBlockID(sealedBlockID flow.Identifier, sealID *flow.Identifier) func(*badger.Txn) error { 64 return retrieve(makePrefix(codeBlockIDToFinalizedSeal, sealedBlockID), &sealID) 65 } 66 67 func InsertExecutionForkEvidence(conflictingSeals []*flow.IncorporatedResultSeal) func(*badger.Txn) error { 68 return insert(makePrefix(codeExecutionFork), conflictingSeals) 69 } 70 71 func RemoveExecutionForkEvidence() func(*badger.Txn) error { 72 return remove(makePrefix(codeExecutionFork)) 73 } 74 75 func RetrieveExecutionForkEvidence(conflictingSeals *[]*flow.IncorporatedResultSeal) func(*badger.Txn) error { 76 return retrieve(makePrefix(codeExecutionFork), conflictingSeals) 77 }