bdledger-apis/bdchain/api/tx_ledger.proto
2019-04-23 18:25:47 +08:00

89 lines
3.0 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package bdchain.api.txledger;
import "google/protobuf/empty.proto";
import "bdchain/api/common.proto";
option go_package = "bdchain/sdk/api/grpc/txledger";
option java_package = "bdchain.api.grpc.txledger";
option java_outer_classname = "TransactionLedgerProto";
option java_multiple_files = true;
service TransactionLedger {
rpc ClientVersion (google.protobuf.Empty) returns (common.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; // 事务的哈希
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 {
string name = 1;
}
message CreateLedgerResponse {
bool ok = 1;
}
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 {
common.TransactionType type = 1;
bytes from = 2;
bytes to = 3;
bytes data = 4;
}
Transaction transaction = 2;
}
message SendTransactionResponse {
bytes hash = 1;
}