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