github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/receipts.go (about) 1 package storage 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 ) 6 7 // ExecutionReceipts holds and indexes Execution Receipts. The storage-layer 8 // abstraction is from the viewpoint of the network: there are multiple 9 // execution nodes which produce several receipts for each block. By default, 10 // there is no distinguished execution node (the are all equal). 11 type ExecutionReceipts interface { 12 13 // Store stores an execution receipt. 14 Store(receipt *flow.ExecutionReceipt) error 15 16 // BatchStore stores an execution receipt inside given batch 17 BatchStore(receipt *flow.ExecutionReceipt, batch BatchStorage) error 18 19 // ByID retrieves an execution receipt by its ID. 20 ByID(receiptID flow.Identifier) (*flow.ExecutionReceipt, error) 21 22 // ByBlockID retrieves all known execution receipts for the given block 23 // (from any Execution Node). 24 ByBlockID(blockID flow.Identifier) (flow.ExecutionReceiptList, error) 25 } 26 27 // MyExecutionReceipts reuses the storage.ExecutionReceipts API, but doesn't expose 28 // them. Instead, it includes the "My" in the method name in order to highlight the notion 29 // of "MY execution receipt", from the viewpoint of an individual Execution Node. 30 type MyExecutionReceipts interface { 31 // StoreMyReceipt stores the receipt and marks it as mine (trusted). My 32 // receipts are indexed by the block whose result they compute. Currently, 33 // we only support indexing a _single_ receipt per block. Attempting to 34 // store conflicting receipts for the same block will error. 35 StoreMyReceipt(receipt *flow.ExecutionReceipt) error 36 37 // BatchStoreMyReceipt stores blockID-to-my-receipt index entry keyed by blockID in a provided batch. 38 // No errors are expected during normal operation 39 // If entity fails marshalling, the error is wrapped in a generic error and returned. 40 // If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned. 41 BatchStoreMyReceipt(receipt *flow.ExecutionReceipt, batch BatchStorage) error 42 43 // MyReceipt retrieves my receipt for the given block. 44 MyReceipt(blockID flow.Identifier) (*flow.ExecutionReceipt, error) 45 46 // BatchRemoveIndexByBlockID removes blockID-to-my-execution-receipt index entry keyed by a blockID in a provided batch 47 // No errors are expected during normal operation, even if no entries are matched. 48 // If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned. 49 BatchRemoveIndexByBlockID(blockID flow.Identifier, batch BatchStorage) error 50 }