bdledger-apis/bdledger/api/query.proto
2020-03-07 13:15:29 +08:00

90 lines
2.3 KiB
Protocol Buffer

syntax = "proto3";
package bdledger.api;
import "bdledger/api/common.proto";
option go_package = "bdware.org/bdledger/pkg/api/grpc/proto";
option java_package = "bdledger.api.grpc.query";
option java_outer_classname = "QueryProto";
option java_multiple_files = true;
service Query {
rpc GetBlockByHash (GetBlockByHashRequest) returns (GetBlockByHashResponse);
rpc GetBlocks (BlocksRequest) returns (GetBlocksResponse);
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);
}
message BlockFilter {
bytes hash = 1;
int64 timestamp = 2;
}
// repeated Transaction/BlockFilters are combined by "&&"(and) operator;
message TransactionFilter {
bytes hash = 1;
bytes from = 2;
bytes to = 3;
bytes timestamp = 4;
}
message GetBlockByHashRequest {
string ledger = 1;
bytes hash = 2;
bool full_transactions = 3;
}
message GetBlockByHashResponse {
Block block = 1;
}
message BlocksRequest {
string ledger = 1;
repeated BlockFilter filters = 2;
int64 start_timestamp = 3; // required
int64 end_timestamp = 4;
}
message GetBlocksResponse {
repeated Block blocks = 1;
int64 start_timestamp = 2;
int64 end_timestamp = 3;
}
message CountBlocksResponse {
uint64 count = 1;
}
message GetTransactionByHashRequest {
string ledger = 1;
bytes hash = 2;
}
message GetTransactionByHashResponse {
Transaction transaction = 1;
}
message GetTransactionByBlockHashAndIndexRequest {
string ledger = 1;
bytes block_hash = 2;
uint32 index = 3;
}
message GetTransactionByBlockHashAndIndexResponse {
Transaction transaction = 1;
}
message TransactionsRequest {
string ledger = 1;
repeated TransactionFilter filters = 2;
int64 start_timestamp = 3; // required
int64 end_timestamp = 4;
}
message GetTransactionsResponse {
repeated Transaction transactions = 1;
int64 start_timestamp = 2;
int64 end_timestamp = 3;
}
message CountTransactionsResponse {
uint64 count = 1;
}