Add query.GetRecentBlocks

This commit is contained in:
Nex
2020-09-04 12:22:44 +08:00
parent 9cf9fb061b
commit d775b43e96

View File

@@ -25,6 +25,11 @@ service Query {
* 查询帐本中的所有区块数量,或时间范围内的区块数量
*/
rpc CountBlocks (BlocksRequest) returns (CountBlocksResponse);
/**
* Get recent 'count' blocks (Only support IncludeTransactions=NONE for now)
* 查询最新的n个区块
*/
rpc GetRecentBlocks (RecentBlocksRequest) returns (GetBlocksResponse);
/**
* Get a transaction identified by its hash
* 查询哈希所指定的事务
@@ -48,6 +53,12 @@ service Query {
rpc CountTransactions (TransactionsRequest) returns (CountTransactionsResponse);
}
enum IncludeTransactions {
NONE = 0; // 不包含交易数据
HASH = 1; // 包含交易哈希列表
FULL = 2; // 包含完整交易列表
}
message BlockFilter {
bytes hash = 1;
int64 timestamp = 2;
@@ -75,11 +86,6 @@ message BlocksRequest {
int64 start_timestamp = 2;
int64 end_timestamp = 3;
repeated BlockFilter filters = 4;
enum IncludeTransactions {
NONE = 0; // 不包含交易数据
HASH = 1; // 包含交易哈希列表
FULL = 2; // 包含完整交易列表
}
IncludeTransactions include_transactions = 5;
}
message GetBlocksResponse {
@@ -93,6 +99,12 @@ message CountBlocksResponse {
int64 end_timestamp = 3;
}
message RecentBlocksRequest {
string ledger = 1;
int64 count = 2;
IncludeTransactions include_transactions = 3;
}
message GetTransactionByHashRequest {
string ledger = 1;
bytes hash = 2;