@@ -124,7 +124,7 @@ func BlockExists(r storage.Reader, blockID flow.Identifier) (bool, error) {
124124 return KeyExists (r , MakePrefix (codeHeader , blockID ))
125125}
126126
127- // IndexCollectionGuaranteeByBlock produces a mapping from collection ID to the block ID containing this collection.
127+ // IndexBlockContainingCollection produces a mapping from collection ID to the block ID containing this collection.
128128//
129129// CAUTION:
130130// - The caller must acquire the lock ??? and hold it until the database write has been committed.
@@ -137,12 +137,21 @@ func BlockExists(r storage.Reader, blockID flow.Identifier) (bool, error) {
137137//
138138// Expected errors during normal operations:
139139// TODO: return [storage.ErrAlreadyExists] or [storage.ErrDataMismatch]
140- func IndexCollectionGuaranteeByBlock (w storage.Writer , collID flow.Identifier , blockID flow.Identifier ) error {
140+ func IndexBlockContainingCollection (w storage.Writer , collID flow.Identifier , blockID flow.Identifier ) error {
141141 return UpsertByKey (w , MakePrefix (codeCollectionBlock , collID ), blockID )
142142}
143143
144- // LookupCollectionGuaranteeByBlock looks up a block by a collection within that block.
145- func LookupCollectionGuaranteeByBlock (r storage.Reader , collID flow.Identifier , blockID * flow.Identifier ) error {
144+ // LookupBlockContainingCollection retrieves the block containing the collection with the given ID.
145+ //
146+ // CAUTION: A collection can be included in multiple *unfinalized* blocks. However, the implementation
147+ // assumes a one-to-one map from collection ID to a *single* block ID. This holds for FINALIZED BLOCKS ONLY
148+ // *and* only in the ABSENCE of BYZANTINE collector CLUSTERS (which the mature protocol must tolerate).
149+ // Hence, this function should be treated as a temporary solution, which requires generalization
150+ // (one-to-many mapping) for soft finality and the mature protocol.
151+ //
152+ // Expected errors during normal operations:
153+ // - [storage.ErrNotFound] if no block is known that contains the specified collection ID.
154+ func LookupBlockContainingCollection (r storage.Reader , collID flow.Identifier , blockID * flow.Identifier ) error {
146155 return RetrieveByKey (r , MakePrefix (codeCollectionBlock , collID ), blockID )
147156}
148157
0 commit comments