2019-11-25 13:23:49 +00:00
|
|
|
syntax = "proto3";
|
|
|
|
|
2020-01-08 02:03:39 +00:00
|
|
|
package bdledger.api;
|
2019-11-25 13:23:49 +00:00
|
|
|
|
|
|
|
import "bdledger/api/common.proto";
|
|
|
|
|
2020-01-08 02:03:39 +00:00
|
|
|
option go_package = "bdware.org/bdledger/pkg/api/grpc/proto";
|
|
|
|
option java_package = "bdledger.api.grpc.query";
|
|
|
|
option java_outer_classname = "QueryProto";
|
2019-11-25 13:23:49 +00:00
|
|
|
option java_multiple_files = true;
|
|
|
|
|
|
|
|
service Query {
|
2020-03-07 05:15:29 +00:00
|
|
|
rpc GetBlockByHash (GetBlockByHashRequest) returns (GetBlockByHashResponse);
|
2020-03-09 16:10:34 +00:00
|
|
|
rpc GetBlocks (BlocksRequest) returns (GetBlocksResponse); // start_timestamp is required
|
2020-03-07 05:15:29 +00:00
|
|
|
rpc CountBlocks (BlocksRequest) returns (CountBlocksResponse);
|
|
|
|
rpc GetTransactionByHash (GetTransactionByHashRequest) returns (GetTransactionByHashResponse);
|
|
|
|
rpc GetTransactionByBlockHashAndIndex (GetTransactionByBlockHashAndIndexRequest) returns (GetTransactionByBlockHashAndIndexResponse);
|
|
|
|
rpc GetTransactions (TransactionsRequest) returns (GetTransactionsResponse);
|
|
|
|
rpc CountTransactions (TransactionsRequest) returns (CountTransactionsResponse);
|
2020-03-06 02:01:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message BlockFilter {
|
2020-03-07 05:15:29 +00:00
|
|
|
bytes hash = 1;
|
|
|
|
int64 timestamp = 2;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// repeated Transaction/BlockFilters are combined by "&&"(and) operator;
|
|
|
|
message TransactionFilter {
|
2020-03-07 05:15:29 +00:00
|
|
|
bytes hash = 1;
|
|
|
|
bytes from = 2;
|
|
|
|
bytes to = 3;
|
|
|
|
bytes timestamp = 4;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 02:01:02 +00:00
|
|
|
message GetBlockByHashRequest {
|
2020-03-07 05:15:29 +00:00
|
|
|
string ledger = 1;
|
|
|
|
bytes hash = 2;
|
|
|
|
bool full_transactions = 3;
|
2020-03-06 02:01:02 +00:00
|
|
|
}
|
|
|
|
message GetBlockByHashResponse {
|
2020-03-07 05:15:29 +00:00
|
|
|
Block block = 1;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message BlocksRequest {
|
2020-03-07 05:15:29 +00:00
|
|
|
string ledger = 1;
|
2020-03-09 16:10:34 +00:00
|
|
|
int64 start_timestamp = 2;
|
2020-03-09 14:28:26 +00:00
|
|
|
int64 end_timestamp = 3;
|
|
|
|
repeated BlockFilter filters = 4;
|
2020-04-02 09:24:11 +00:00
|
|
|
enum IncludeTransactions {
|
|
|
|
NONE = 0; // 不包含交易数据
|
|
|
|
HASH = 1; // 包含交易哈希列表
|
|
|
|
FULL = 2; // 包含完整交易列表
|
|
|
|
}
|
|
|
|
IncludeTransactions include_transactions = 5;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
message GetBlocksResponse {
|
2020-03-07 05:15:29 +00:00
|
|
|
repeated Block blocks = 1;
|
|
|
|
int64 start_timestamp = 2;
|
|
|
|
int64 end_timestamp = 3;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
message CountBlocksResponse {
|
2020-03-07 05:15:29 +00:00
|
|
|
uint64 count = 1;
|
2020-04-02 09:23:36 +00:00
|
|
|
int64 start_timestamp = 2;
|
|
|
|
int64 end_timestamp = 3;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message GetTransactionByHashRequest {
|
2020-03-07 05:15:29 +00:00
|
|
|
string ledger = 1;
|
|
|
|
bytes hash = 2;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
message GetTransactionByHashResponse {
|
2020-03-07 05:15:29 +00:00
|
|
|
Transaction transaction = 1;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message GetTransactionByBlockHashAndIndexRequest {
|
2020-03-07 05:15:29 +00:00
|
|
|
string ledger = 1;
|
|
|
|
bytes block_hash = 2;
|
|
|
|
uint32 index = 3;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
|
|
|
message GetTransactionByBlockHashAndIndexResponse {
|
2020-03-07 05:15:29 +00:00
|
|
|
Transaction transaction = 1;
|
2019-11-25 13:23:49 +00:00
|
|
|
}
|
2020-03-06 02:01:02 +00:00
|
|
|
|
|
|
|
message TransactionsRequest {
|
2020-03-07 05:15:29 +00:00
|
|
|
string ledger = 1;
|
2020-03-09 14:28:26 +00:00
|
|
|
int64 start_timestamp = 2; // required
|
|
|
|
int64 end_timestamp = 3;
|
|
|
|
repeated TransactionFilter filters = 4;
|
2020-03-06 02:01:02 +00:00
|
|
|
}
|
|
|
|
message GetTransactionsResponse {
|
2020-03-07 05:15:29 +00:00
|
|
|
repeated Transaction transactions = 1;
|
|
|
|
int64 start_timestamp = 2;
|
|
|
|
int64 end_timestamp = 3;
|
2020-03-06 02:01:02 +00:00
|
|
|
}
|
|
|
|
message CountTransactionsResponse {
|
2020-03-07 05:15:29 +00:00
|
|
|
uint64 count = 1;
|
2020-04-02 09:23:36 +00:00
|
|
|
int64 start_timestamp = 2;
|
|
|
|
int64 end_timestamp = 3;
|
2020-03-06 02:01:02 +00:00
|
|
|
}
|