-
Notifications
You must be signed in to change notification settings - Fork 6
/
chaincode.proto
242 lines (205 loc) · 6.88 KB
/
chaincode.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// Gateway to network/chaincode
// Two types of gateways: 1. Gateway to all chaincodes in Network 2. Gateway to some concrete chaincode instance in some channel
syntax = "proto3";
option go_package = "github.com/hyperledger-labs/cckit/gateway";
package cckit.gateway;
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "hyperledger/fabric/peer/proposal_response.proto";
import "hyperledger/fabric/peer/chaincode_event.proto";
import "mwitkow/go-proto-validators/validator.proto";
// Chaincode communication service. Allows to locate channel/chaincode.
service ChaincodeService {
// Exec: Query or Invoke
rpc Exec (ChaincodeExecRequest) returns (protos.Response) {
option (google.api.http) = {
post: "/chaincode/exec"
body: "*"
};
}
// Query chaincode on home peer. Do NOT send to orderer.
rpc Query (ChaincodeQueryRequest) returns (protos.Response) {
option (google.api.http) = {
get: "/chaincode/query"
};
}
// Invoke chaincode on peers, according to endorsement policy and the SEND to orderer
rpc Invoke (ChaincodeInvokeRequest) returns (protos.Response) {
option (google.api.http) = {
post: "/chaincode/invoke"
body: "*"
};
}
// Chaincode events stream
rpc EventsStream (ChaincodeEventsStreamRequest) returns (stream ChaincodeEvent) {
option (google.api.http) = {
get: "/chaincode/events-stream"
};
}
// Chaincode events
rpc Events (ChaincodeEventsRequest) returns (ChaincodeEvents) {
option (google.api.http) = {
get: "/chaincode/events"
};
}
}
// Chaincode events subscription service
service ChaincodeEventsService {
// Chaincode events stream
rpc EventsStream (ChaincodeEventsStreamRequest) returns (stream ChaincodeEvent) {
option (google.api.http) = {
get: "/chaincode/events-stream"
};
}
// Chaincode events
rpc Events (ChaincodeEventsRequest) returns (ChaincodeEvents) {
option (google.api.http) = {
get: "/chaincode/events"
};
}
}
// Chaincode instance communication service. Channel/chaincode already fixed.
service ChaincodeInstanceService {
// Exec: Query or Invoke
rpc Exec (ChaincodeInstanceExecRequest) returns (protos.Response) {
option (google.api.http) = {
post: "/chaincode-instance/exec"
body: "*"
};
}
// Query chaincode on home peer. Do NOT send to orderer.
rpc Query (ChaincodeInstanceQueryRequest) returns (protos.Response) {
option (google.api.http) = {
get: "/chaincode-instance/query"
};
}
// Invoke chaincode on peers, according to endorsement policy and the SEND to orderer
rpc Invoke (ChaincodeInstanceInvokeRequest) returns (protos.Response) {
option (google.api.http) = {
post: "/chaincode-instance/invoke"
body: "*"
};
}
// Chaincode events stream
rpc EventsStream (ChaincodeInstanceEventsStreamRequest) returns (stream ChaincodeEvent) {
option (google.api.http) = {
get: "/chaincode-instance/events-stream"
};
}
// Chaincode events
rpc Events (ChaincodeInstanceEventsRequest) returns (ChaincodeEvents) {
option (google.api.http) = {
get: "/chaincode-instance/events"
};
}
}
// Chaincode instance events subscription service
service ChaincodeInstanceEventsService {
// Chaincode events stream
rpc EventsStream (ChaincodeInstanceEventsStreamRequest) returns (stream ChaincodeEvent) {
option (google.api.http) = {
get: "/chaincode-instance/events-stream"
};
}
// Chaincode events s
rpc Events (ChaincodeInstanceEventsRequest) returns (ChaincodeEvents) {
option (google.api.http) = {
get: "/chaincode-instance/events"
};
}
}
// Chaincode locator - channel name and chaincode name
message ChaincodeLocator {
// Chaincode name
string chaincode = 1 [(validator.field) = {string_not_empty : true}];
// Channel name
string channel = 2 [(validator.field) = {string_not_empty : true}];
}
// Chaincode invocation input
message ChaincodeInput {
// Input contains the arguments for invocation.
repeated bytes args = 1;
// TransientMap contains data (e.g. cryptographic material) that might be used
// to implement some form of application-level confidentiality. The contents
// of this field are supposed to always be omitted from the transaction and
// excluded from the ledger.
map<string, bytes> transient = 2;
}
// Chaincode invocation type
enum InvocationType {
// Simulation
INVOCATION_TYPE_QUERY = 0;
// Simulation and applying to ledger
INVOCATION_TYPE_INVOKE = 1;
}
// Chaincode execution specification
message ChaincodeExecRequest {
ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
InvocationType type = 2;
ChaincodeInput input = 3;
}
message ChaincodeQueryRequest {
ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
ChaincodeInput input = 3;
}
message ChaincodeInvokeRequest {
ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
ChaincodeInput input = 3;
}
// Block limit number for event stream subscription or event list
// Values can be negative
message BlockLimit {
// Block number
int64 num = 1;
}
// Chaincode events stream request
message ChaincodeEventsStreamRequest {
ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
BlockLimit from_block = 2;
BlockLimit to_block = 3;
repeated string event_name = 4;
}
// Chaincode events list request
message ChaincodeEventsRequest {
ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
BlockLimit from_block = 2;
BlockLimit to_block = 3;
repeated string event_name = 4;
uint32 limit = 5;
}
message ChaincodeInstanceExecRequest {
InvocationType type = 1;
ChaincodeInput input = 2;
}
message ChaincodeInstanceQueryRequest {
ChaincodeInput input = 1;
}
message ChaincodeInstanceInvokeRequest {
ChaincodeInput input = 1;
}
message ChaincodeInstanceEventsStreamRequest {
BlockLimit from_block = 1;
BlockLimit to_block = 2;
repeated string event_name = 3;
}
message ChaincodeInstanceEventsRequest {
BlockLimit from_block = 1;
BlockLimit to_block = 2;
repeated string event_name = 3;
uint32 limit = 4;
}
message ChaincodeEvents {
ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
BlockLimit from_block = 2;
BlockLimit to_block = 3;
repeated ChaincodeEvent items = 4;
}
message RawJson {
bytes value = 1;
}
message ChaincodeEvent {
protos.ChaincodeEvent event = 1;
uint64 block = 2;
google.protobuf.Timestamp tx_timestamp = 3;
RawJson payload = 4;
}