Update proto files and scripts
This commit is contained in:
97
bg/api/ac_chain.proto
Normal file
97
bg/api/ac_chain.proto
Normal file
@@ -0,0 +1,97 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bg.api;
|
||||
|
||||
import "bg/api/common.proto";
|
||||
|
||||
option go_package = "bg/api/protobuf/ac_chain";
|
||||
option java_package = "bg.protobuf";
|
||||
option java_outer_classname = "AcChainProto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
service AcChain {
|
||||
rpc BlockNumber (BlockNumberRequest) returns (BlockNumberResponse);
|
||||
rpc GetBlockByNumber (GetBlockByNumberRequest) returns (GetBlockByNumberResponse);
|
||||
rpc GetBlockByHash (GetBlockByHashRequest) returns (GetBlockByHashResponse);
|
||||
rpc GetMessageByHash (GetMessageByHashRequest) returns (GetMessageByHashResponse);
|
||||
rpc GetMessageByBlockNumberAndIndex (GetMessageByBlockNumberAndIndexRequest) returns (GetMessageByBlockNumberAndIndexResponse);
|
||||
rpc GetMessageByBlockHashAndIndex (GetMessageByBlockHashAndIndexRequest) returns (GetMessageByBlockHashAndIndexResponse);
|
||||
}
|
||||
|
||||
message Message {
|
||||
uint64 block_number = 1; // 消息所在的区块的区块号,当消息处于待确认状态时为`null`
|
||||
bytes block_hash = 2; // 消息所在的区块的哈希,当消息处于待确认状态时为`null`
|
||||
uint32 index = 3; // 消息在区块中的位置index,当消息处于待确认状态时为`null`
|
||||
bytes hash = 4; // 消息的哈希
|
||||
MessageType 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; // 父区块的哈希
|
||||
bytes witness = 4; // 见证者账户地址
|
||||
uint64 timestamp = 5; // 区块产生时的UNIX时间戳
|
||||
uint64 size = 6; // 区块大小的字节数
|
||||
bytes message_root = 7; // 区块的消息树根
|
||||
repeated Message messages = 8; // 消息对象的数组,或为空
|
||||
repeated bytes message_hashes = 9; // 32字节的交易哈希的数组,或为空
|
||||
}
|
||||
|
||||
message BlockNumberRequest {
|
||||
string ledger = 1;
|
||||
}
|
||||
message BlockNumberResponse {
|
||||
uint64 block_number = 1;
|
||||
}
|
||||
|
||||
message GetBlockByNumberRequest {
|
||||
string ledger = 1;
|
||||
uint64 number = 2;
|
||||
bool full_transaction = 3;
|
||||
}
|
||||
message GetBlockByNumberResponse {
|
||||
Block block = 1;
|
||||
}
|
||||
|
||||
message GetBlockByHashRequest {
|
||||
string ledger = 1;
|
||||
bytes hash = 2;
|
||||
bool full_transaction = 3;
|
||||
}
|
||||
message GetBlockByHashResponse {
|
||||
Block block = 1;
|
||||
}
|
||||
|
||||
message GetMessageByHashRequest {
|
||||
string ledger = 1;
|
||||
bytes hash = 2;
|
||||
}
|
||||
message GetMessageByHashResponse {
|
||||
Message message = 1;
|
||||
}
|
||||
|
||||
message GetMessageByBlockNumberAndIndexRequest {
|
||||
string ledger = 1;
|
||||
uint64 block_number = 2;
|
||||
uint32 index = 3;
|
||||
}
|
||||
message GetMessageByBlockNumberAndIndexResponse {
|
||||
Message message = 1;
|
||||
}
|
||||
|
||||
message GetMessageByBlockHashAndIndexRequest {
|
||||
string ledger = 1;
|
||||
bytes block_hash = 2;
|
||||
uint32 index = 3;
|
||||
}
|
||||
message GetMessageByBlockHashAndIndexResponse {
|
||||
Message message = 1;
|
||||
}
|
||||
15
bg/api/common.proto
Normal file
15
bg/api/common.proto
Normal file
@@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bg.api;
|
||||
|
||||
option go_package = "bg/api/protobuf/common";
|
||||
option java_package = "bg.protobuf";
|
||||
option java_outer_classname = "CommonProto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
enum MessageType {
|
||||
RECORD = 0; // 通用数据记录
|
||||
TRANSACTION = 1; // 交易
|
||||
CONTRACT_CREATION = 2; // 合约创建
|
||||
CONTRACT_INVOCATION = 3; // 合约调用
|
||||
}
|
||||
43
bg/api/tx_ledger.proto
Normal file
43
bg/api/tx_ledger.proto
Normal file
@@ -0,0 +1,43 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bg.api;
|
||||
|
||||
import "bg/api/common.proto";
|
||||
|
||||
option go_package = "bg/api/protobuf/tx_ledger";
|
||||
option java_package = "bg.protobuf";
|
||||
option java_outer_classname = "TxLedgerProto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
service TxLedger {
|
||||
rpc CreateLedger (CreateLedgerRequest) returns (CreateLedgerResponse);
|
||||
rpc GetLedgers (GetLedgersRequest) returns (GetLedgersResponse);
|
||||
rpc SendMessage (SendMessageRequest) returns (SendMessageResponse);
|
||||
}
|
||||
|
||||
message CreateLedgerRequest {
|
||||
string name = 1;
|
||||
}
|
||||
message CreateLedgerResponse {
|
||||
bool ok = 1;
|
||||
}
|
||||
|
||||
message GetLedgersRequest {
|
||||
}
|
||||
message GetLedgersResponse {
|
||||
repeated string ledgers = 1;
|
||||
}
|
||||
|
||||
message SendMessageRequest {
|
||||
string ledger = 1;
|
||||
message Message {
|
||||
MessageType type = 1;
|
||||
bytes from = 2;
|
||||
bytes to = 3;
|
||||
bytes data = 4;
|
||||
}
|
||||
Message message = 2;
|
||||
}
|
||||
message SendMessageResponse {
|
||||
bytes hash = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user