add hash query
Summary: add TransactionCount/GetTransactions 增加关于 transaction/block 相关的查询接口 Test Plan: none Reviewers: nex, wuyi Reviewed By: nex Differential Revision: https://phabricator.internetapi.cn/D25
This commit is contained in:
parent
3dc5c90025
commit
de035bd3bc
@ -1,84 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package bdledger.api.acchain;
|
|
||||||
|
|
||||||
import "google/protobuf/empty.proto";
|
|
||||||
import "bdledger/api/common.proto";
|
|
||||||
|
|
||||||
option go_package = "bdware.org/bdledger/sdk/api/grpc/acchain";
|
|
||||||
option java_package = "bdledger.api.grpc.acchain";
|
|
||||||
option java_outer_classname = "AccountingChainProto";
|
|
||||||
option java_multiple_files = true;
|
|
||||||
|
|
||||||
service AccountingChain {
|
|
||||||
rpc ClientVersion (google.protobuf.Empty) returns (common.ClientVersionResponse);
|
|
||||||
rpc BlockNumber (BlockNumberRequest) returns (BlockNumberResponse);
|
|
||||||
rpc GetBlockByNumber (GetBlockByNumberRequest) returns (Block);
|
|
||||||
rpc GetBlockByHash (GetBlockByHashRequest) returns (Block);
|
|
||||||
rpc GetTransactionByHash (GetTransactionByHashRequest) returns (Transaction);
|
|
||||||
rpc GetTransactionByBlockNumberAndIndex (GetTransactionByBlockNumberAndIndexRequest) returns (Transaction);
|
|
||||||
rpc GetTransactionByBlockHashAndIndex (GetTransactionByBlockHashAndIndexRequest) returns (Transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
message Transaction {
|
|
||||||
uint64 block_number = 1; // 事务所在的区块的区块号,当事务处于待确认状态时为`null`
|
|
||||||
bytes block_hash = 2; // 事务所在的区块的哈希,当事务处于待确认状态时为`null`
|
|
||||||
uint32 index = 3; // 事务在区块中的位置index,当事务处于待确认状态时为`null`
|
|
||||||
bytes hash = 4; // 事务的哈希
|
|
||||||
common.TransactionType type = 5; // 事务类型
|
|
||||||
bytes from = 6; // 发送账户地址
|
|
||||||
uint64 nonce = 7; // 这条事务之前发送者所发送的事务数量
|
|
||||||
bytes to = 8; // 接收账户地址,或者调用的合约地址,或者`null`如为合约创建
|
|
||||||
bytes data = 9; // 数据或合约代码
|
|
||||||
bytes v = 10; // ECDSA recovery id
|
|
||||||
bytes r = 11; // ECDSA signature r
|
|
||||||
bytes s = 12; // ECDSA signature s
|
|
||||||
}
|
|
||||||
|
|
||||||
message Block {
|
|
||||||
uint64 number = 1; // 区块号,当区块处于待确认状态时为`null`
|
|
||||||
bytes hash = 2; // 区块的哈希,当区块处于待确认状态时为`null`
|
|
||||||
bytes parent_hash = 3; // 父区块的哈希
|
|
||||||
repeated bytes witnesses = 4; // 见证者账户地址的数组
|
|
||||||
int64 timestamp = 5; // 区块产生时的UNIX时间戳
|
|
||||||
uint64 size = 6; // 区块大小的字节数
|
|
||||||
bytes transactions_root = 7; // 区块的事务树根
|
|
||||||
repeated Transaction transactions = 8; // 事务对象的数组,或为空
|
|
||||||
repeated bytes transaction_hashes = 9; // 20字节的交易哈希的数组,或为空
|
|
||||||
}
|
|
||||||
|
|
||||||
message BlockNumberRequest {
|
|
||||||
string ledger = 1;
|
|
||||||
}
|
|
||||||
message BlockNumberResponse {
|
|
||||||
uint64 block_number = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetBlockByNumberRequest {
|
|
||||||
string ledger = 1;
|
|
||||||
uint64 number = 2;
|
|
||||||
bool full_transaction = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetBlockByHashRequest {
|
|
||||||
string ledger = 1;
|
|
||||||
bytes hash = 2;
|
|
||||||
bool full_transaction = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetTransactionByHashRequest {
|
|
||||||
string ledger = 1;
|
|
||||||
bytes hash = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetTransactionByBlockNumberAndIndexRequest {
|
|
||||||
string ledger = 1;
|
|
||||||
uint64 block_number = 2;
|
|
||||||
uint32 index = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetTransactionByBlockHashAndIndexRequest {
|
|
||||||
string ledger = 1;
|
|
||||||
bytes block_hash = 2;
|
|
||||||
uint32 index = 3;
|
|
||||||
}
|
|
@ -19,3 +19,29 @@ enum TransactionType {
|
|||||||
CONTRACT_INVOCATION = 3; // 合约调用
|
CONTRACT_INVOCATION = 3; // 合约调用
|
||||||
CONTRACT_STATUS = 4; // 合约状态
|
CONTRACT_STATUS = 4; // 合约状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Transaction {
|
||||||
|
bytes block_hash = 1; // 事务所在的区块的哈希,当事务处于待确认状态时为`null`
|
||||||
|
uint32 index = 2; // 事务在区块中的位置 index,当事务处于待确认状态时为`null`
|
||||||
|
bytes hash = 3; // 事务的哈希
|
||||||
|
common.TransactionType type = 4; // 事务类型
|
||||||
|
bytes from = 5; // 发送账户地址
|
||||||
|
uint64 nonce = 6; // 这条事务之前发送者所发送的事务数量
|
||||||
|
bytes to = 7; // 接收账户地址,或者调用的合约地址,或者`null`如为合约创建
|
||||||
|
bytes data = 8; // 数据或合约代码
|
||||||
|
bytes v = 9; // ECDSA recovery id
|
||||||
|
bytes r = 10; // ECDSA signature r
|
||||||
|
bytes s = 11; // ECDSA signature s
|
||||||
|
}
|
||||||
|
|
||||||
|
message Block {
|
||||||
|
uint64 index = 1; // 事务链本地区块索引,当区块处于待确认状态时为`null`
|
||||||
|
bytes hash = 2; // 区块的哈希,当区块处于待确认状态时为`null`
|
||||||
|
repeated bytes parent_hashes = 3; // 父区块的哈希
|
||||||
|
repeated bytes witnesses = 4; // 见证者账户地址
|
||||||
|
int64 timestamp = 5; // 区块产生时的 UNIX 时间戳,单位为秒
|
||||||
|
uint64 size = 6; // 区块大小的字节数
|
||||||
|
bytes transactions_root = 7; // 区块的事务树根
|
||||||
|
repeated Transaction transactions = 8; // 事务对象的数组,或为空
|
||||||
|
repeated bytes transaction_hashes = 9; // 20字节的交易哈希的数组,或为空
|
||||||
|
}
|
89
bdledger/api/query_service.proto
Normal file
89
bdledger/api/query_service.proto
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package bdledger.api.txledger;
|
||||||
|
|
||||||
|
import "bdledger/api/common.proto";
|
||||||
|
|
||||||
|
option go_package = "bdware.org/bdledger/sdk/api/grpc/txledger";
|
||||||
|
option java_package = "bdledger.api.grpc.txledger";
|
||||||
|
option java_outer_classname = "TransactionLedgerProto";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
service Query {
|
||||||
|
rpc GetBlocks (BlocksRequest) returns (GetBlocksResponse);
|
||||||
|
rpc CountBlocks (BlocksRequest) returns (CountBlocksResponse);
|
||||||
|
rpc GetTransactions(TransactionsRequest) returns (GetTransactionsResponse);
|
||||||
|
rpc CountTransactions(TransactionsRequest) returns (CountTransactionsResponse);
|
||||||
|
rpc GetBlockByHash (GetBlockByHashRequest) returns (GetBlockByHashResponse);
|
||||||
|
rpc GetTransactionByHash (GetTransactionByHashRequest) returns (GetTransactionByHashResponse);
|
||||||
|
rpc GetTransactionByBlockHashAndIndex (GetTransactionByBlockHashAndIndexRequest) returns (GetTransactionByBlockHashAndIndexResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
// repeated Transaction/BlockFilters are combined by "&&"(and) operator;
|
||||||
|
message TransactionFilter {
|
||||||
|
bytes hash = 1;
|
||||||
|
bytes from = 2;
|
||||||
|
bytes to = 3;
|
||||||
|
bytes timestamp = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BlockFilter {
|
||||||
|
bytes hash = 1;
|
||||||
|
int64 timestamp = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BlocksRequest {
|
||||||
|
string ledger = 1;
|
||||||
|
repeated BlockFilter filters = 2;
|
||||||
|
required int64 start_timestamp = 3;
|
||||||
|
int64 end_timestamp = 4;
|
||||||
|
}
|
||||||
|
message GetBlocksResponse {
|
||||||
|
repeated common.Block blocks= 1;
|
||||||
|
int64 start_timestamp = 2;
|
||||||
|
int64 end_timestamp = 3;
|
||||||
|
}
|
||||||
|
message CountBlocksResponse {
|
||||||
|
uint64 count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TransactionsRequest {
|
||||||
|
string ledger = 1;
|
||||||
|
repeated TransactionFilter filters = 2;
|
||||||
|
required int64 start_timestamp = 3;
|
||||||
|
int64 end_timestamp = 4;
|
||||||
|
}
|
||||||
|
message GetTransactionsResponse {
|
||||||
|
repeated common.Transaction Transactions = 1;
|
||||||
|
int64 start_timestamp = 2;
|
||||||
|
int64 end_timestamp = 3;
|
||||||
|
}
|
||||||
|
message CountTransactionsResponse {
|
||||||
|
uint64 count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetBlockByHashRequest {
|
||||||
|
string ledger = 1;
|
||||||
|
bytes hash = 2;
|
||||||
|
bool full_transaction = 3;
|
||||||
|
}
|
||||||
|
message GetBlockByHashResponse {
|
||||||
|
common.Block block = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTransactionByHashRequest {
|
||||||
|
string ledger = 1;
|
||||||
|
bytes hash = 2;
|
||||||
|
}
|
||||||
|
message GetTransactionByHashResponse {
|
||||||
|
common.Transaction transaction = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTransactionByBlockHashAndIndexRequest {
|
||||||
|
string ledger = 1;
|
||||||
|
bytes block_hash = 2;
|
||||||
|
uint32 index = 3;
|
||||||
|
}
|
||||||
|
message GetTransactionByBlockHashAndIndexResponse {
|
||||||
|
common.Transaction transaction = 1;
|
||||||
|
}
|
@ -19,32 +19,6 @@ service TransactionLedger {
|
|||||||
rpc SendTransaction (SendTransactionRequest) returns (SendTransactionResponse);
|
rpc SendTransaction (SendTransactionRequest) returns (SendTransactionResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
message Transaction {
|
|
||||||
bytes block_hash = 1; // 事务所在的区块的哈希,当事务处于待确认状态时为`null`
|
|
||||||
uint32 index = 2; // 事务在区块中的位置 index,当事务处于待确认状态时为`null`
|
|
||||||
bytes hash = 3; // 事务的哈希
|
|
||||||
common.TransactionType type = 4; // 事务类型
|
|
||||||
bytes from = 5; // 发送账户地址
|
|
||||||
uint64 nonce = 6; // 这条事务之前发送者所发送的事务数量
|
|
||||||
bytes to = 7; // 接收账户地址,或者调用的合约地址,或者`null`如为合约创建
|
|
||||||
bytes data = 8; // 数据或合约代码
|
|
||||||
bytes v = 9; // ECDSA recovery id
|
|
||||||
bytes r = 10; // ECDSA signature r
|
|
||||||
bytes s = 11; // ECDSA signature s
|
|
||||||
}
|
|
||||||
|
|
||||||
message Block {
|
|
||||||
uint64 index = 1; // 事务链本地区块索引,当区块处于待确认状态时为`null`
|
|
||||||
bytes hash = 2; // 区块的哈希,当区块处于待确认状态时为`null`
|
|
||||||
repeated bytes parent_hashes = 3; // 父区块的哈希
|
|
||||||
repeated bytes witnesses = 4; // 见证者账户地址
|
|
||||||
int64 timestamp = 5; // 区块产生时的 UNIX 时间戳,单位为秒
|
|
||||||
uint64 size = 6; // 区块大小的字节数
|
|
||||||
bytes transactions_root = 7; // 区块的事务树根
|
|
||||||
repeated Transaction transactions = 8; // 事务对象的数组,或为空
|
|
||||||
repeated bytes transaction_hashes = 9; // 20字节的交易哈希的数组,或为空
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateLedgerRequest {
|
message CreateLedgerRequest {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
}
|
}
|
||||||
@ -70,7 +44,7 @@ message GetBlocksRequest {
|
|||||||
bool full_transaction = 4;
|
bool full_transaction = 4;
|
||||||
}
|
}
|
||||||
message GetBlocksResponse {
|
message GetBlocksResponse {
|
||||||
repeated Block blocks = 1;
|
repeated common.Block blocks = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SendTransactionRequest {
|
message SendTransactionRequest {
|
||||||
|
@ -12,6 +12,6 @@ if not exist %dir% mkdir %dir%
|
|||||||
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/common.proto
|
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/common.proto
|
||||||
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/error_details.proto
|
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/error_details.proto
|
||||||
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/tx_ledger.proto
|
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/tx_ledger.proto
|
||||||
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/ac_chain.proto
|
%exe% -I . --go_out=plugins=grpc:%dir% bdledger/api/query_service.proto
|
||||||
|
|
||||||
echo all done
|
echo all done
|
||||||
|
@ -3,4 +3,4 @@ mkdir -p gen/go
|
|||||||
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/common.proto
|
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/common.proto
|
||||||
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/error_details.proto
|
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/error_details.proto
|
||||||
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/tx_ledger.proto
|
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/tx_ledger.proto
|
||||||
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/ac_chain.proto
|
protoc -I . --go_out=plugins=grpc:gen/go bdledger/api/query_service.proto
|
||||||
|
@ -10,6 +10,6 @@ if not exist %dir% mkdir %dir%
|
|||||||
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/common.proto
|
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/common.proto
|
||||||
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/error_details.proto
|
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/error_details.proto
|
||||||
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/tx_ledger.proto
|
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/tx_ledger.proto
|
||||||
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/ac_chain.proto
|
%exe% -I . --js_out=import_style=commonjs:%dir% --grpc-web_out=import_style=commonjs,mode=grpcwebtext:%dir% bdledger/api/query_service.proto
|
||||||
|
|
||||||
echo all done
|
echo all done
|
||||||
|
@ -4,4 +4,4 @@ mkdir -p $dir
|
|||||||
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/common.proto
|
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/common.proto
|
||||||
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/error_details.proto
|
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/error_details.proto
|
||||||
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/tx_ledger.proto
|
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/tx_ledger.proto
|
||||||
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/ac_chain.proto
|
protoc -I . --js_out=import_style=commonjs:$dir --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$dir bdledger/api/query_service.proto
|
||||||
|
Loading…
Reference in New Issue
Block a user