24
24
import org .hyperledger .fabric .protos .peer .ChaincodeEventPackage .ChaincodeEvent ;
25
25
import org .hyperledger .fabric .protos .peer .ProposalResponsePackage .Response ;
26
26
import org .hyperledger .fabric .shim .ledger .CompositeKey ;
27
+ import org .hyperledger .fabric .shim .ledger .KeyValue ;
28
+ import org .hyperledger .fabric .shim .ledger .QueryResultsIterator ;
27
29
28
30
public interface ChaincodeStub {
29
31
@@ -49,7 +51,7 @@ public interface ChaincodeStub {
49
51
* A convenience method that returns the first argument of the chaincode
50
52
* invocation for use as a function name.
51
53
*
52
- * The bytes of the first argument are decoded as a UTF-8 string.
54
+ * The bytes of the first argument are decoded as a UTF-8 string.
53
55
*
54
56
* @return the function name
55
57
*/
@@ -77,9 +79,12 @@ public interface ChaincodeStub {
77
79
/**
78
80
* Invoke another chaincode using the same transaction context.
79
81
*
80
- * @param chaincodeName Name of chaincode to be invoked.
81
- * @param args Arguments to pass on to the called chaincode.
82
- * @param channel If not specified, the caller's channel is assumed.
82
+ * @param chaincodeName
83
+ * Name of chaincode to be invoked.
84
+ * @param args
85
+ * Arguments to pass on to the called chaincode.
86
+ * @param channel
87
+ * If not specified, the caller's channel is assumed.
83
88
* @return
84
89
*/
85
90
Response invokeChaincode (String chaincodeName , List <byte []> args , String channel );
@@ -89,8 +94,7 @@ public interface ChaincodeStub {
89
94
*
90
95
* @param key
91
96
* name of the value
92
- * @return value
93
- * the value read from the ledger
97
+ * @return value the value read from the ledger
94
98
*/
95
99
byte [] getState (String key );
96
100
@@ -112,20 +116,48 @@ public interface ChaincodeStub {
112
116
*/
113
117
void delState (String key );
114
118
119
+ /**
120
+ * Returns all existing keys, and their values, that are lexicographically
121
+ * between <code>startkey</code> (inclusive) and the <code>endKey</code>
122
+ * (exclusive).
123
+ *
124
+ * @param startKey
125
+ * @param endKey
126
+ * @return an {@link Iterable} of {@link KeyValue}
127
+ */
128
+ QueryResultsIterator <KeyValue > getStateByRange (String startKey , String endKey );
129
+
130
+ /**
131
+ * Returns all existing keys, and their values, that are prefixed by the
132
+ * specified partial {@link CompositeKey}.
133
+ *
134
+ * If a full composite key is specified, it will not match itself, resulting
135
+ * in no keys being returned.
136
+ *
137
+ * @param compositeKey
138
+ * partial composite key
139
+ * @return an {@link Iterable} of {@link KeyValue}
140
+ */
141
+ QueryResultsIterator <KeyValue > getStateByPartialCompositeKey (String compositeKey );
142
+
115
143
/**
116
144
* Given a set of attributes, this method combines these attributes to
117
145
* return a composite key.
118
146
*
119
147
* @param objectType
120
148
* @param attributes
121
149
* @return a composite key
150
+ * @throws CompositeKeyFormatException
151
+ * if any parameter contains either a U+000000 or U+10FFFF code
152
+ * point.
122
153
*/
123
154
CompositeKey createCompositeKey (String objectType , String ... attributes );
124
155
125
156
/**
126
157
* Parses a composite key from a string.
127
158
*
128
- * @param compositeKey a composite key string
159
+ * @param compositeKey
160
+ * a composite key string
129
161
* @return a composite key
130
162
*/
131
163
CompositeKey splitCompositeKey (String compositeKey );
@@ -144,8 +176,10 @@ public interface ChaincodeStub {
144
176
/**
145
177
* Invoke another chaincode using the same transaction context.
146
178
*
147
- * @param chaincodeName Name of chaincode to be invoked.
148
- * @param args Arguments to pass on to the called chaincode.
179
+ * @param chaincodeName
180
+ * Name of chaincode to be invoked.
181
+ * @param args
182
+ * Arguments to pass on to the called chaincode.
149
183
* @return
150
184
*/
151
185
default Response invokeChaincode (String chaincodeName , List <byte []> args ) {
@@ -155,27 +189,33 @@ default Response invokeChaincode(String chaincodeName, List<byte[]> args) {
155
189
/**
156
190
* Invoke another chaincode using the same transaction context.
157
191
*
158
- * This is a convenience version of {@link #invokeChaincode(String, List, String)}.
159
- * The string args will be encoded into as UTF-8 bytes.
192
+ * This is a convenience version of
193
+ * {@link #invokeChaincode(String, List, String)}. The string args will be
194
+ * encoded into as UTF-8 bytes.
160
195
*
161
- * @param chaincodeName Name of chaincode to be invoked.
162
- * @param args Arguments to pass on to the called chaincode.
163
- * @param channel If not specified, the caller's channel is assumed.
196
+ * @param chaincodeName
197
+ * Name of chaincode to be invoked.
198
+ * @param args
199
+ * Arguments to pass on to the called chaincode.
200
+ * @param channel
201
+ * If not specified, the caller's channel is assumed.
164
202
* @return
165
203
*/
166
204
default Response invokeChaincodeWithStringArgs (String chaincodeName , List <String > args , String channel ) {
167
- return invokeChaincode (chaincodeName , args .stream ().map (x -> x .getBytes (UTF_8 )).collect (toList ()), channel );
205
+ return invokeChaincode (chaincodeName , args .stream ().map (x -> x .getBytes (UTF_8 )).collect (toList ()), channel );
168
206
}
169
207
170
208
/**
171
209
* Invoke another chaincode using the same transaction context.
172
210
*
173
211
* This is a convenience version of {@link #invokeChaincode(String, List)}.
174
- * The string args will be encoded into as UTF-8 bytes.
212
+ * The string args will be encoded into as UTF-8 bytes.
175
213
*
176
214
*
177
- * @param chaincodeName Name of chaincode to be invoked.
178
- * @param args Arguments to pass on to the called chaincode.
215
+ * @param chaincodeName
216
+ * Name of chaincode to be invoked.
217
+ * @param args
218
+ * Arguments to pass on to the called chaincode.
179
219
* @return
180
220
*/
181
221
default Response invokeChaincodeWithStringArgs (String chaincodeName , List <String > args ) {
@@ -186,11 +226,13 @@ default Response invokeChaincodeWithStringArgs(String chaincodeName, List<String
186
226
* Invoke another chaincode using the same transaction context.
187
227
*
188
228
* This is a convenience version of {@link #invokeChaincode(String, List)}.
189
- * The string args will be encoded into as UTF-8 bytes.
229
+ * The string args will be encoded into as UTF-8 bytes.
190
230
*
191
231
*
192
- * @param chaincodeName Name of chaincode to be invoked.
193
- * @param args Arguments to pass on to the called chaincode.
232
+ * @param chaincodeName
233
+ * Name of chaincode to be invoked.
234
+ * @param args
235
+ * Arguments to pass on to the called chaincode.
194
236
* @return
195
237
*/
196
238
default Response invokeChaincodeWithStringArgs (final String chaincodeName , final String ... args ) {
@@ -203,8 +245,7 @@ default Response invokeChaincodeWithStringArgs(final String chaincodeName, final
203
245
*
204
246
* @param key
205
247
* name of the value
206
- * @return value
207
- * the value read from the ledger
248
+ * @return value the value read from the ledger
208
249
*/
209
250
default String getStringState (String key ) {
210
251
return new String (getState (key ), UTF_8 );
@@ -225,6 +266,7 @@ default void putStringState(String key, String value) {
225
266
/**
226
267
* Returns the CHAINCODE type event that will be posted to interested
227
268
* clients when the chaincode's result is committed to the ledger.
269
+ *
228
270
* @return the chaincode event or null
229
271
*/
230
272
ChaincodeEvent getEvent ();
0 commit comments