39
39
40
40
class ChaincodeStubImpl implements ChaincodeStub {
41
41
42
+ private final String channelId ;
42
43
private final String txId ;
43
44
private final Handler handler ;
44
45
private final List <ByteString > args ;
45
46
private ChaincodeEvent event ;
46
47
47
- ChaincodeStubImpl (String txId , Handler handler , List <ByteString > args ) {
48
+ ChaincodeStubImpl (String channelId , String txId , Handler handler , List <ByteString > args ) {
49
+ this .channelId = channelId ;
48
50
this .txId = txId ;
49
51
this .handler = handler ;
50
52
this .args = Collections .unmodifiableList (args );
@@ -90,30 +92,35 @@ public ChaincodeEvent getEvent() {
90
92
return event ;
91
93
}
92
94
95
+ @ Override
96
+ public String getChannelId () {
97
+ return channelId ;
98
+ }
99
+
93
100
@ Override
94
101
public String getTxId () {
95
102
return txId ;
96
103
}
97
104
98
105
@ Override
99
106
public byte [] getState (String key ) {
100
- return handler .getState (txId , key ).toByteArray ();
107
+ return handler .getState (channelId , txId , key ).toByteArray ();
101
108
}
102
109
103
110
@ Override
104
111
public void putState (String key , byte [] value ) {
105
- handler .putState (txId , key , ByteString .copyFrom (value ));
112
+ handler .putState (channelId , txId , key , ByteString .copyFrom (value ));
106
113
}
107
114
108
115
@ Override
109
116
public void delState (String key ) {
110
- handler .deleteState (txId , key );
117
+ handler .deleteState (channelId , txId , key );
111
118
}
112
119
113
120
@ Override
114
121
public QueryResultsIterator <KeyValue > getStateByRange (String startKey , String endKey ) {
115
- return new QueryResultsIteratorImpl <KeyValue >(this .handler , getTxId (),
116
- handler .getStateByRange (getTxId (), startKey , endKey ),
122
+ return new QueryResultsIteratorImpl <KeyValue >(this .handler , getChannelId (), getTxId (),
123
+ handler .getStateByRange (getChannelId (), getTxId (), startKey , endKey ),
117
124
queryResultBytesToKv .andThen (KeyValueImpl ::new )
118
125
);
119
126
}
@@ -145,16 +152,16 @@ public CompositeKey splitCompositeKey(String compositeKey) {
145
152
146
153
@ Override
147
154
public QueryResultsIterator <KeyValue > getQueryResult (String query ) {
148
- return new QueryResultsIteratorImpl <KeyValue >(this .handler , getTxId (),
149
- handler .getQueryResult (getTxId (), query ),
155
+ return new QueryResultsIteratorImpl <KeyValue >(this .handler , getChannelId (), getTxId (),
156
+ handler .getQueryResult (getChannelId (), getTxId (), query ),
150
157
queryResultBytesToKv .andThen (KeyValueImpl ::new )
151
158
);
152
159
}
153
160
154
161
@ Override
155
162
public QueryResultsIterator <KeyModification > getHistoryForKey (String key ) {
156
- return new QueryResultsIteratorImpl <KeyModification >(this .handler , getTxId (),
157
- handler .getHistoryForKey (getTxId (), key ),
163
+ return new QueryResultsIteratorImpl <KeyModification >(this .handler , getChannelId (), getTxId (),
164
+ handler .getHistoryForKey (getChannelId (), getTxId (), key ),
158
165
queryResultBytesToKeyModification .andThen (KeyModificationImpl ::new )
159
166
);
160
167
}
@@ -178,7 +185,7 @@ public Response invokeChaincode(final String chaincodeName, final List<byte[]> a
178
185
} else {
179
186
compositeName = chaincodeName ;
180
187
}
181
- return handler .invokeChaincode (this .txId , compositeName , args );
188
+ return handler .invokeChaincode (this .channelId , this . txId , compositeName , args );
182
189
}
183
190
184
191
}
0 commit comments