Skip to content

Commit e53629d

Browse files
committed
[FAB-11989] Clarify error handling for plugins
Change-Id: I3d77a06158b78b0e2df3123ba68edcb4add3150c Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net> Signed-off-by: Matthias Neugschwandtner <eug@zurich.ibm.com>
1 parent 757a4cf commit e53629d

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

docs/source/pluggable_endorsement_and_validation.rst

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,24 @@ Currently Fabric comes with the following dependencies for validation plugins:
255255
256256
// State defines interaction with the world state
257257
type State interface {
258-
// GetStateMultipleKeys gets the values for multiple keys in a single call
259-
GetStateMultipleKeys(namespace string, keys []string) ([][]byte, error)
258+
// GetStateMultipleKeys gets the values for multiple keys in a single call
259+
GetStateMultipleKeys(namespace string, keys []string) ([][]byte, error)
260260
261-
// GetStateRangeScanIterator returns an iterator that contains all the key-values between given key ranges.
262-
// startKey is included in the results and endKey is excluded. An empty startKey refers to the first available key
263-
// and an empty endKey refers to the last available key. For scanning all the keys, both the startKey and the endKey
264-
// can be supplied as empty strings. However, a full scan should be used judiciously for performance reasons.
265-
// The returned ResultsIterator contains results of type *KV which is defined in protos/ledger/queryresult.
266-
GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ResultsIterator, error)
261+
// GetStateRangeScanIterator returns an iterator that contains all the key-values between given key ranges.
262+
// startKey is included in the results and endKey is excluded. An empty startKey refers to the first available key
263+
// and an empty endKey refers to the last available key. For scanning all the keys, both the startKey and the endKey
264+
// can be supplied as empty strings. However, a full scan should be used judiciously for performance reasons.
265+
// The returned ResultsIterator contains results of type *KV which is defined in protos/ledger/queryresult.
266+
GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ResultsIterator, error)
267267
268-
// Done releases resources occupied by the State
269-
Done()
268+
// GetStateMetadata returns the metadata for given namespace and key
269+
GetStateMetadata(namespace, key string) (map[string][]byte, error)
270+
271+
// GetPrivateDataMetadata gets the metadata of a private data item identified by a tuple <namespace, collection, key>
272+
GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error)
273+
274+
// Done releases resources occupied by the State
275+
Done()
270276
}
271277
272278
Important notes
@@ -290,6 +296,13 @@ Important notes
290296
of marking the transaction as invalid. This is to prevent state divergence
291297
between different peers.
292298

299+
- **Error handling for private metadata retrieval**: In case a plugin retrieves
300+
metadata for private data by making use of the ``StateFetcher`` interface,
301+
it is important that errors are handled as follows: ``CollConfigNotDefinedError''
302+
and ``InvalidCollNameError'', signalling that the specified collection does
303+
not exist, should be handled as deterministic errors and should not lead the
304+
plugin to return an ``ExecutionFailureError``.
305+
293306
- **Importing Fabric code into the plugin**: Importing code that belongs to Fabric
294307
other than protobufs as part of the plugin is highly discouraged, and can lead
295308
to issues when the Fabric code changes between releases, or can cause inoperability

0 commit comments

Comments
 (0)