github.com/lzy4123/fabric@v2.1.1+incompatible/core/handlers/validation/api/state/state.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package validation 8 9 import ( 10 validation "github.com/hyperledger/fabric/core/handlers/validation/api" 11 ) 12 13 // State defines interaction with the world state 14 type State interface { 15 // GetStateMultipleKeys gets the values for multiple keys in a single call 16 GetStateMultipleKeys(namespace string, keys []string) ([][]byte, error) 17 18 // GetStateRangeScanIterator returns an iterator that contains all the key-values between given key ranges. 19 // startKey is included in the results and endKey is excluded. An empty startKey refers to the first available key 20 // and an empty endKey refers to the last available key. For scanning all the keys, both the startKey and the endKey 21 // can be supplied as empty strings. However, a full scan should be used judiciously for performance reasons. 22 // The returned ResultsIterator contains results of type *KV which is defined in fabric-protos/ledger/queryresult. 23 GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ResultsIterator, error) 24 25 // GetStateMetadata returns the metadata for given namespace and key 26 GetStateMetadata(namespace, key string) (map[string][]byte, error) 27 28 // GetPrivateDataMetadataByHash gets the metadata of a private data item identified by a tuple <namespace, collection, keyhash> 29 GetPrivateDataMetadataByHash(namespace, collection string, keyhash []byte) (map[string][]byte, error) 30 31 // Done releases resources occupied by the State 32 Done() 33 } 34 35 // StateFetcher retrieves an instance of a state 36 type StateFetcher interface { 37 validation.Dependency 38 39 // FetchState fetches state 40 FetchState() (State, error) 41 } 42 43 // ResultsIterator - an iterator for query result set 44 type ResultsIterator interface { 45 // Next returns the next item in the result set. The `QueryResult` is expected to be nil when 46 // the iterator gets exhausted 47 Next() (QueryResult, error) 48 // Close releases resources occupied by the iterator 49 Close() 50 } 51 52 // QueryResult - a general interface for supporting different types of query results. Actual types differ for different queries 53 type QueryResult interface{}