Skip to content

Commit b9fbca4

Browse files
committed
cleanup of documentation and error returns
1 parent d7105b1 commit b9fbca4

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

storage/operation/guarantees.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,13 @@ import (
1616
// guarantee! This method silently overrides existing data, which is safe only if for the same
1717
// key, we always write the same value.
1818
//
19-
// Expected errors during normal operations:
20-
// - generic error in case of unexpected failure from the database layer or encoding failure.
19+
// No errors expected during normal operations.
2120
func InsertGuarantee(w storage.Writer, guaranteeID flow.Identifier, guarantee *flow.CollectionGuarantee) error {
2221
return UpsertByKey(w, MakePrefix(codeGuarantee, guaranteeID), guarantee)
2322
}
2423

2524
// IndexGuarantee inserts a [flow.CollectionGuarantee] into the database, keyed by the collection ID.
2625
//
27-
// CAUTION:
28-
// - The caller must acquire the [storage.LockInsertBlock] and hold it until the database write has been committed.
29-
// - OVERWRITES existing data (potential for data corruption):
30-
// This method silently overrides existing data without any sanity checks whether data for the same key already exists.
31-
// Note that the Flow protocol mandates that for a previously persisted key, the data is never changed to a different
32-
// value. Changing data could cause the node to publish inconsistent data and to be slashed, or the protocol to be
33-
// compromised as a whole. This method does not contain any safeguards to prevent such data corruption. The lock proof
34-
// serves as a reminder that the CALLER is responsible to ensure that the DEDUPLICATION CHECK is done elsewhere
35-
// ATOMICALLY with this write operation.
36-
//
3726
// Expected errors during normal operations:
3827
// - [storage.ErrDataMismatch] if a different [flow.CollectionGuarantee] has already been indexed for the given collection ID.
3928
// - All other errors have to be treated as unexpected failures from the database layer.
@@ -91,9 +80,7 @@ func LookupGuarantee(r storage.Reader, collectionID flow.Identifier, guaranteeID
9180
// serves as a reminder that the CALLER is responsible to ensure that the DEDUPLICATION CHECK is done elsewhere
9281
// ATOMICALLY with this write operation.
9382
//
94-
// Error returns:
95-
// - [storage.ErrAlreadyExists] if the key already exists in the database.
96-
// - All other errors have to be treated as unexpected failures from the database layer.
83+
// No errors expected during normal operations.
9784
func IndexPayloadGuarantees(lctx lockctx.Proof, w storage.Writer, blockID flow.Identifier, guarIDs []flow.Identifier) error {
9885
if !lctx.HoldsLock(storage.LockInsertBlock) {
9986
return fmt.Errorf("cannot index guarantee for blockID %v without holding lock %s",

storage/procedure/index.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ import (
1010
"github.com/onflow/flow-go/storage/operation"
1111
)
1212

13+
// InsertIndex persists the given index keyed by the block ID
14+
//
15+
// CAUTION:
16+
// - The caller must acquire the [storage.LockInsertBlock] and hold it until the database write has been committed.
17+
// - OVERWRITES existing data (potential for data corruption):
18+
// This method silently overrides existing data without any sanity checks whether data for the same key already exits.
19+
// Note that the Flow protocol mandates that for a previously persisted key, the data is never changed to a different
20+
// value. Changing data could cause the node to publish inconsistent data and to be slashed, or the protocol to be
21+
// compromised as a whole. This method does not contain any safeguards to prevent such data corruption. The lock proof
22+
// serves as a reminder that the CALLER is responsible to ensure that the DEDUPLICATION CHECK is done elsewhere
23+
// ATOMICALLY with this write operation.
24+
//
25+
// No errors expected during normal operations.
1326
func InsertIndex(lctx lockctx.Proof, rw storage.ReaderBatchWriter, blockID flow.Identifier, index *flow.Index) error {
1427
if !lctx.HoldsLock(storage.LockInsertBlock) {
1528
return fmt.Errorf("missing required lock: %s", storage.LockInsertBlock)

0 commit comments

Comments
 (0)