github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/collections.go (about) 1 package storage 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 ) 6 7 // Collections represents persistent storage for collections. 8 type Collections interface { 9 10 // StoreLight inserts the collection. It does not insert, nor check 11 // existence of, the constituent transactions. 12 StoreLight(collection *flow.LightCollection) error 13 14 // Store inserts the collection keyed by ID and all constituent 15 // transactions. 16 Store(collection *flow.Collection) error 17 18 // Remove removes the collection and all constituent transactions. 19 Remove(collID flow.Identifier) error 20 21 // LightByID returns collection with the given ID. Only retrieves 22 // transaction hashes. 23 LightByID(collID flow.Identifier) (*flow.LightCollection, error) 24 25 // ByID returns the collection with the given ID, including all 26 // transactions within the collection. 27 ByID(collID flow.Identifier) (*flow.Collection, error) 28 29 // StoreLightAndIndexByTransaction inserts the light collection (only 30 // transaction IDs) and adds a transaction id index for each of the 31 // transactions within the collection (transaction_id->collection_id). 32 // 33 // NOTE: Currently it is possible in rare circumstances for two collections 34 // to be guaranteed which both contain the same transaction (see https://github.com/dapperlabs/flow-go/issues/3556). 35 // The second of these will revert upon reaching the execution node, so 36 // this doesn't impact the execution state, but it can result in the Access 37 // node processing two collections which both contain the same transaction (see https://github.com/dapperlabs/flow-go/issues/5337). 38 // To handle this, we skip indexing the affected transaction when inserting 39 // the transaction_id->collection_id index when an index for the transaction 40 // already exists. 41 StoreLightAndIndexByTransaction(collection *flow.LightCollection) error 42 43 // LightByTransactionID returns the collection for the given transaction ID. Only retrieves 44 // transaction hashes. 45 LightByTransactionID(txID flow.Identifier) (*flow.LightCollection, error) 46 }