1. Add new TxLedger APIs: BlockCount, GetBlocks

2. Update AcChain APIs
3. Change hashes from 32 bytes to 20 bytes
This commit is contained in:
Nex
2018-12-11 15:57:06 +08:00
parent 07f1e05962
commit def8e3feab
3 changed files with 402 additions and 33 deletions

View File

@@ -39,7 +39,7 @@ message Block {
uint64 number = 1; // 区块号,当区块处于待确认状态时为`null`
bytes hash = 2; // 区块的哈希,当区块处于待确认状态时为`null`
bytes parent_hash = 3; // 父区块的哈希
bytes witness = 4; // 见证者账户地址
repeated bytes witnesses = 4; // 见证者账户地址的数组
uint64 timestamp = 5; // 区块产生时的UNIX时间戳
uint64 size = 6; // 区块大小的字节数
bytes transactions_root = 7; // 区块的事务树根

View File

@@ -14,9 +14,37 @@ service TransactionLedger {
rpc ClientVersion (google.protobuf.Empty) returns (ClientVersionResponse);
rpc CreateLedger (CreateLedgerRequest) returns (CreateLedgerResponse);
rpc GetLedgers (google.protobuf.Empty) returns (GetLedgersResponse);
rpc BlockCount (BlockCountRequest) returns (BlockCountResponse);
rpc GetBlocks (GetBlocksRequest) returns (GetBlocksResponse);
rpc SendTransaction (SendTransactionRequest) returns (SendTransactionResponse);
}
message Transaction {
bytes block_hash = 1; // 事务所在的区块的哈希,当事务处于待确认状态时为`null`
uint32 index = 2; // 事务在区块中的位置index当事务处于待确认状态时为`null`
bytes hash = 3; // 事务的哈希
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; // 父区块的哈希
bytes witness = 4; // 见证者账户地址
uint64 timestamp = 5; // 区块产生时的UNIX时间戳
uint64 size = 6; // 区块大小的字节数
bytes transactions_root = 7; // 区块的事务树根
repeated Transaction transactions = 8; // 事务对象的数组,或为空
repeated bytes transaction_hashes = 9; // 32字节的交易哈希的数组或为空
}
message CreateLedgerRequest {
string name = 1;
}
@@ -28,6 +56,23 @@ message GetLedgersResponse {
repeated string ledgers = 1;
}
message BlockCountRequest {
string ledger = 1;
}
message BlockCountResponse {
uint64 block_count = 1;
}
message GetBlocksRequest {
string ledger = 1;
uint64 from_index = 2;
uint32 count = 3; // Optional, default to 10, max value is 10
bool full_transaction = 4;
}
message GetBlocksResponse {
repeated Block blocks = 1;
}
message SendTransactionRequest {
string ledger = 1;
message Transaction {