/
apidiag.thrift
359 lines (314 loc) · 7.93 KB
/
apidiag.thrift
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
include 'general.thrift'
namespace csharp NodeApiDiag
namespace netcore NodeApiDiag
namespace java com.credits.client.node.diag.thrift.generated
namespace cpp api_diag
struct TransactionId
{
// block
1: i64 sequence
// 0-based index in block
2: i16 index
}
// Unix timestamp in milliseconds
typedef i64 Time
typedef i64 TransactionInnerId
struct AmountCommission
{
1: required i16 bits
2: double value
}
struct Money
{
// Exact value
1: general.Amount amount
// amount in double format
2: double value
}
struct ContractDeploy
{
1: string sourceCode
2: list<general.ByteCodeObject> byteCodeObjects
3: i32 tokenStandard
}
struct ContractCall
{
// try call as getter
1: bool getter
2: string method
// Empty on deploy, method params stringified Java-side with conversion to string on execute
3: list<general.Variant> params //general.Variant+
// If true, do not emit any transactions to blockchain (execute contract and forget state change if any)
4: list<general.Address> uses
}
struct ContractState
{
// true - stored state hash, false - stored state itself (elder transactions only)
1: bool hashed
// if hashed == true contains hash, otherwise contains state itself
2: string content
// ref start
3: TransactionId call
// fee for execution
4: Money fee
// returned value
5: string returned
}
union Contract
{
// Contract deployment
1: ContractDeploy deploy
// Contract invocation
2: ContractCall call
// Contract result state
3: ContractState state
}
union UserFielData
{
1: i64 integer
// Binary data or text
2: string bytes
3: general.Amount amount
}
struct UserField
{
1: i8 id
2: UserFielData data
}
enum TransactionType
{
// 0 | CS transfer, former TT_Normal
TT_Transfer,
// 1 | contract deployment, former TT_SmartDeploy
TT_ContractDeploy,
// 2 | Contract execution, former TT_SmartExecute
TT_ContractCall,
// 3 | Contract new state, TT_SmartState
TT_ContractState,
// 4 | Contract replenish (indirect payable() invocation)
TT_ContractReplenish,
// 5 | Token deployment
TT_TokenDeploy,
// 6 | Token transfer
TT_TokenTransfer,
// 7 | Stake delegation to node address
TT_Delegation,
// 8 | Cancel stake delegation
TT_RevokeDelegation,
// 9 | Put some transfer on hold until some codition to release or cancel
TT_Hold,
// 10 | Release previously hold sum to complete transfer
TT_Release,
// 11 | Revoke hold to cancel the transfer
TT_CancelHold,
// 12 | Transfer delayed until some moment
TT_DelayedTransfer,
// 13 | Service: update current boostrap node list with new one
TT_UpdateBootstrapList,
// 14 | Service: update current settings
TT_UpdateSettings,
// 15 | Malformed (invalid) transaction
TT_Malformed,
// 16 | Contract emitted transaction
TT_ContractEmitted,
// 17 | Utility transaction
TT_Utility,
// 18 | Any other type
TT_Other,
}
struct TransactionData
{
// Inner transaction ID for protection against replay attack
1: TransactionInnerId id
// Sender or contract deployer/invoker.
// In general, the public key to test signature
2: general.Address source
// Receiver or contract address
3: general.Address target
// Transfer amount for payment transaction
4: Money sum
// Fee limitation
6: AmountCommission max_fee
// Actual fee to withdraw from source
7: AmountCommission actual_fee
// Signature is formed against node's custom binary serialization format,
// see other docs for description
8: binary signature
9: Time timestamp
10: TransactionType type
// user fields if any, does not include special contract-related fields
11: optional list<UserField> userFields
12: optional Contract contract
}
struct NodeData
{
1: i16 short_value
2: i64 ulong_value
3: general.Address publicKey
}
struct GetTransactionResponse
{
1: general.APIResponse status
2: optional TransactionData transaction
}
//////////////////// Starter proto /////////////////////////
enum Platform
{
OS_Linux, // = 0
OS_MacOS, // = 1
OS_Windows // = 2
}
// Active nodes
struct ServerNode
{
// endpoint.address().to_string()
1: string ip
// std::to_string(uint16_t)
2: string port
// std::to_string(NODE_VERSION)
3: string version
// Utils::byteStreamToHex(cs::Hash);
4: string hash
// Utils::byteStreamToHex(cs::PublicKey);
5: string publicKey
// enum Platform to string
6: string platform
// integer
7: i32 countTrust
// std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())
8: i64 timeRegistration
// now - timeRegistration - timeNotActive
9: i64 timeActive
}
struct ActiveNodesResult
{
1: general.APIResponse result
2: list<ServerNode> nodes
}
struct ActiveTransactionsResult
{
1: general.APIResponse result
2: string count
}
//////////////////// Starter proto end /////////////////////
struct SessionInfo
{
1: i64 startRound
2: i64 curRound
3: i64 lastBlock
4: i64 uptimeMs
5: i64 aveRoundMs
}
struct StageCacheSize
{
1: i64 stage1
2: i64 stage2
3: i64 stage3
}
struct StateInfo
{
1: i64 transactionsCount
2: i64 totalWalletsCount
3: i64 aliveWalletsCount
4: i64 contractsCount
5: i64 contractsQueueSize
6: i64 grayListSize
7: i64 blackListSize
8: i64 blockCacheSize
9: StageCacheSize consensusMessage
10: StageCacheSize contractsMessage
11: StageCacheSize contractsStorage
}
struct BootstrapNode
{
1: string id
2: bool alive
3: i64 sequence
}
struct NodeInfo
{
1: string id
2: string version
3: Platform platform
4: optional SessionInfo session
5: optional StateInfo state
6: optional list<string> grayListContent
7: optional list<string> blackListContent
8: optional list<BootstrapNode> bootstrap
}
struct NodeInfoRequest
{
1: bool session
2: bool state
3: bool grayListContent
4: bool blackListContent
}
struct NodeInfoRespone
{
1: general.APIResponse result
2: NodeInfo info
}
struct ServerTrustNode
{
// endpoint.address().to_string()
1: string ip
// std::to_string(uint16_t)
2: string port
// std::to_string(NODE_VERSION)
3: string version
// Utils::byteStreamToHex(cs::Hash);
4: string hash
// Utils::byteStreamToHex(cs::PublicKey);
5: string publicKey
// enum Platform to string
6: string platform
// std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())
7: i64 timeRegistration
// now - timeRegistration - timeNotActive
8: i64 timeActive
// integer
9: i32 trustDay
10: i32 trustMonth
11: i32 trustPrevMonth
12: i32 trustTotal
// integer
13: i32 failedTrustDay
14: i32 failedTrustMonth
15: i32 failedTrustPrevMonth
16: i32 failedTrustTotal
17: general.Amount feeDay
18: general.Amount feeMonth
19: general.Amount feePrevMonth
20: general.Amount feeTotal
21: i32 trustedADay
22: i32 trustedAMonth
23: i32 trustedAPrevMonth
24: i32 trustedATotal
25: i32 failedTrustedADay
26: i32 failedTrustedAMonth
27: i32 failedTrustedAPrevMonth
28: i32 failedTrustedATotal
29: bool active
}
struct ActiveTrustNodesResult
{
1: general.APIResponse result
2: list<ServerTrustNode> nodes
}
service API_DIAG {
// Former starter node protocol
// returns nodes from server buffer
ActiveNodesResult GetActiveNodes()
ActiveTrustNodesResult GetActiveTrustNodes()
// returns active transactions count
ActiveTransactionsResult GetActiveTransactionsCount()
// Diagnostic support
// get detailed transaction info
GetTransactionResponse GetTransaction(1:TransactionId id)
// get detailed node info
NodeInfoRespone GetNodeInfo(1: NodeInfoRequest request)
general.APIResponse AddNeighbour(1: string publicKey)
general.APIResponse SetRawData(1: string data)
general.APIResponse UserCommand(1: string data)
general.APIResponse SetNodeBehaviour(1: NodeData data)
}