Skip to content

Commit 65049dc

Browse files
committed
clarified method naming
1 parent 7f58fad commit 65049dc

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

engine/access/ingestion/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func (e *Engine) processFinalizedBlock(block *flow.Block) error {
372372
// TODO: substitute an indexer module as layer between engine and storage
373373

374374
// index the block storage with each of the collection guarantee
375-
err := e.blocks.IndexBlockForCollectionGuarantees(block.ID(), flow.GetIDs(block.Payload.Guarantees))
375+
err := e.blocks.IndexBlockContainingCollectionGuarantee(block.ID(), flow.GetIDs(block.Payload.Guarantees))
376376
if err != nil {
377377
return fmt.Errorf("could not index block for collections: %w", err)
378378
}

engine/access/ingestion2/finalized_block_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (p *FinalizedBlockProcessor) processFinalizedBlockJobCallback(
145145
//
146146
// No errors are expected during normal operations.
147147
func (p *FinalizedBlockProcessor) indexFinalizedBlock(block *flow.Block) error {
148-
err := p.blocks.IndexBlockForCollectionGuarantees(block.ID(), flow.GetIDs(block.Payload.Guarantees))
148+
err := p.blocks.IndexBlockContainingCollectionGuarantee(block.ID(), flow.GetIDs(block.Payload.Guarantees))
149149
if err != nil {
150150
return fmt.Errorf("could not index block for collections: %w", err)
151151
}

storage/blocks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type Blocks interface {
8282
// to decode an existing database value
8383
ByCollectionID(collID flow.Identifier) (*flow.Block, error)
8484

85-
// IndexBlockForCollectionGuarantees populates an index `guaranteeID->blockID` for each guarantee
85+
// IndexBlockContainingCollectionGuarantee populates an index `guaranteeID->blockID` for each guarantee
8686
// which appears in the block.
8787
// CAUTION: a collection can be included in multiple *unfinalized* blocks. However, the implementation
8888
// assumes a one-to-one map from collection ID to a *single* block ID. This holds for FINALIZED BLOCKS ONLY
@@ -92,5 +92,5 @@ type Blocks interface {
9292
//
9393
// Error returns:
9494
// - generic error in case of unexpected failure from the database layer or encoding failure.
95-
IndexBlockForCollectionGuarantees(blockID flow.Identifier, collIDs []flow.Identifier) error
95+
IndexBlockContainingCollectionGuarantee(blockID flow.Identifier, collIDs []flow.Identifier) error
9696
}

storage/operation/headers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func BlockExists(r storage.Reader, blockID flow.Identifier) (bool, error) {
124124
return KeyExists(r, MakePrefix(codeHeader, blockID))
125125
}
126126

127-
// IndexBlockContainingCollection produces a mapping from collection ID to the block ID containing this collection.
127+
// IndexBlockContainingCollectionGuarantee 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,11 +137,11 @@ 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 IndexBlockContainingCollection(w storage.Writer, collID flow.Identifier, blockID flow.Identifier) error {
140+
func IndexBlockContainingCollectionGuarantee(w storage.Writer, collID flow.Identifier, blockID flow.Identifier) error {
141141
return UpsertByKey(w, MakePrefix(codeCollectionBlock, collID), blockID)
142142
}
143143

144-
// LookupBlockContainingCollection retrieves the block containing the collection with the given ID.
144+
// LookupBlockContainingCollectionGuarantee retrieves the block containing the collection with the given ID.
145145
//
146146
// CAUTION: A collection can be included in multiple *unfinalized* blocks. However, the implementation
147147
// assumes a one-to-one map from collection ID to a *single* block ID. This holds for FINALIZED BLOCKS ONLY
@@ -151,7 +151,7 @@ func IndexBlockContainingCollection(w storage.Writer, collID flow.Identifier, bl
151151
//
152152
// Expected errors during normal operations:
153153
// - [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 {
154+
func LookupBlockContainingCollectionGuarantee(r storage.Reader, collID flow.Identifier, blockID *flow.Identifier) error {
155155
return RetrieveByKey(r, MakePrefix(codeCollectionBlock, collID), blockID)
156156
}
157157

storage/operation/headers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ func TestHeaderIDIndexByCollectionID(t *testing.T) {
5555
collectionGuaranteeID := unittest.IdentifierFixture()
5656

5757
err := db.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error {
58-
return operation.IndexBlockContainingCollection(rw.Writer(), collectionGuaranteeID, headerID)
58+
return operation.IndexBlockContainingCollectionGuarantee(rw.Writer(), collectionGuaranteeID, headerID)
5959
})
6060
require.NoError(t, err)
6161

6262
actualID := &flow.Identifier{}
63-
err = operation.LookupBlockContainingCollection(db.Reader(), collectionGuaranteeID, actualID)
63+
err = operation.LookupBlockContainingCollectionGuarantee(db.Reader(), collectionGuaranteeID, actualID)
6464
require.NoError(t, err)
6565
assert.Equal(t, headerID, *actualID)
6666
})

storage/store/blocks.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ func (b *Blocks) ByCollectionID(collID flow.Identifier) (*flow.Block, error) {
196196
return nil, fmt.Errorf("could not look up guarantee: %w", err)
197197
}
198198
var blockID flow.Identifier
199-
err = operation.LookupBlockContainingCollection(b.db.Reader(), guarantee.ID(), &blockID)
199+
err = operation.LookupBlockContainingCollectionGuarantee(b.db.Reader(), guarantee.ID(), &blockID)
200200
if err != nil {
201201
return nil, fmt.Errorf("could not look up block: %w", err)
202202
}
203203
return b.ByID(blockID)
204204
}
205205

206-
// IndexBlockForCollectionGuarantees populates an index `guaranteeID->blockID` for each guarantee
206+
// IndexBlockContainingCollectionGuarantee populates an index `guaranteeID->blockID` for each guarantee
207207
// which appears in the block.
208208
// CAUTION: a collection can be included in multiple *unfinalized* blocks. However, the implementation
209209
// assumes a one-to-one map from collection ID to a *single* block ID. This holds for FINALIZED BLOCKS ONLY
@@ -213,10 +213,10 @@ func (b *Blocks) ByCollectionID(collID flow.Identifier) (*flow.Block, error) {
213213
//
214214
// Error returns:
215215
// - generic error in case of unexpected failure from the database layer or encoding failure.
216-
func (b *Blocks) IndexBlockForCollectionGuarantees(blockID flow.Identifier, guaranteeIDs []flow.Identifier) error {
216+
func (b *Blocks) IndexBlockContainingCollectionGuarantee(blockID flow.Identifier, guaranteeIDs []flow.Identifier) error {
217217
return b.db.WithReaderBatchWriter(func(rw storage.ReaderBatchWriter) error {
218218
for _, guaranteeID := range guaranteeIDs {
219-
err := operation.IndexBlockContainingCollection(rw.Writer(), guaranteeID, blockID)
219+
err := operation.IndexBlockContainingCollectionGuarantee(rw.Writer(), guaranteeID, blockID)
220220
if err != nil {
221221
return fmt.Errorf("could not index collection block (%x): %w", guaranteeID, err)
222222
}

0 commit comments

Comments
 (0)