Update naming

This commit is contained in:
Nex 2018-09-09 19:13:05 +08:00
parent fa403bc24e
commit cafc744da9
5 changed files with 49 additions and 47 deletions

View File

@ -1,31 +1,31 @@
syntax = "proto3";
package bg.api;
package bdchain.api;
import "bg/api/common.proto";
import "bdchain/api/common.proto";
option go_package = "bg/api/protobuf/ac_chain";
option java_package = "bg.protobuf";
option java_outer_classname = "AcChainProto";
option go_package = "bdchain/api/protobuf/ac_chain";
option java_package = "bdchain.protobuf";
option java_outer_classname = "AccountingChainProto";
option java_multiple_files = true;
service AcChain {
service AccountingChain {
rpc BlockNumber (BlockNumberRequest) returns (BlockNumberResponse);
rpc GetBlockByNumber (GetBlockByNumberRequest) returns (Block);
rpc GetBlockByHash (GetBlockByHashRequest) returns (Block);
rpc GetMessageByHash (GetMessageByHashRequest) returns (Block);
rpc GetMessageByBlockNumberAndIndex (GetMessageByBlockNumberAndIndexRequest) returns (Message);
rpc GetMessageByBlockHashAndIndex (GetMessageByBlockHashAndIndexRequest) returns (Message);
rpc GetTransactionByHash (GetTransactionByHashRequest) returns (Block);
rpc GetTransactionByBlockNumberAndIndex (GetTransactionByBlockNumberAndIndexRequest) returns (Transaction);
rpc GetTransactionByBlockHashAndIndex (GetTransactionByBlockHashAndIndexRequest) returns (Transaction);
}
message Message {
uint64 block_number = 1; // `null`
bytes block_hash = 2; // `null`
uint32 index = 3; // index`null`
bytes hash = 4; //
MessageType type = 5; //
message Transaction {
uint64 block_number = 1; // `null`
bytes block_hash = 2; // `null`
uint32 index = 3; // index`null`
bytes hash = 4; //
TransactionType type = 5; //
bytes from = 6; //
uint64 nonce = 7; //
uint64 nonce = 7; //
bytes to = 8; // `null`
bytes data = 9; //
bytes v = 10; // ECDSA recovery id
@ -40,9 +40,9 @@ message Block {
bytes witness = 4; //
uint64 timestamp = 5; // UNIX时间戳
uint64 size = 6; //
bytes message_root = 7; //
repeated Message messages = 8; //
repeated bytes message_hashes = 9; // 32
bytes transactions_root = 7; //
repeated Transaction transactions = 8; //
repeated bytes transaction_hashes = 9; // 32
}
message BlockNumberRequest {
@ -64,18 +64,18 @@ message GetBlockByHashRequest {
bool full_transaction = 3;
}
message GetMessageByHashRequest {
message GetTransactionByHashRequest {
string ledger = 1;
bytes hash = 2;
}
message GetMessageByBlockNumberAndIndexRequest {
message GetTransactionByBlockNumberAndIndexRequest {
string ledger = 1;
uint64 block_number = 2;
uint32 index = 3;
}
message GetMessageByBlockHashAndIndexRequest {
message GetTransactionByBlockHashAndIndexRequest {
string ledger = 1;
bytes block_hash = 2;
uint32 index = 3;

View File

@ -1,15 +1,16 @@
syntax = "proto3";
package bg.api;
package bdchain.api;
option go_package = "bg/api/protobuf/common";
option java_package = "bg.protobuf";
option go_package = "bdchain/api/protobuf/common";
option java_package = "bdchain.protobuf";
option java_outer_classname = "CommonProto";
option java_multiple_files = true;
enum MessageType {
/* 事务类型 */
enum TransactionType {
RECORD = 0; //
TRANSACTION = 1; //
MESSAGE = 1; //
CONTRACT_CREATION = 2; //
CONTRACT_INVOCATION = 3; //
}

View File

@ -1,19 +1,19 @@
syntax = "proto3";
package bg.api;
package bdchain.api;
import "google/protobuf/empty.proto";
import "bg/api/common.proto";
import "bdchain/api/common.proto";
option go_package = "bg/api/protobuf/tx_ledger";
option java_package = "bg.protobuf";
option java_outer_classname = "TxLedgerProto";
option go_package = "bdchain/api/protobuf/tx_ledger";
option java_package = "bdchain.protobuf";
option java_outer_classname = "TransactionLedgerProto";
option java_multiple_files = true;
service TxLedger {
service TransactionLedger {
rpc CreateLedger (CreateLedgerRequest) returns (CreateLedgerResponse);
rpc GetLedgers (google.protobuf.Empty) returns (GetLedgersResponse);
rpc SendMessage (SendMessageRequest) returns (SendMessageResponse);
rpc SendTransaction (SendTransactionRequest) returns (SendTransactionResponse);
}
message CreateLedgerRequest {
@ -27,16 +27,16 @@ message GetLedgersResponse {
repeated string ledgers = 1;
}
message SendMessageRequest {
message SendTransactionRequest {
string ledger = 1;
message Message {
MessageType type = 1;
message Transaction {
TransactionType type = 1;
bytes from = 2;
bytes to = 3;
bytes data = 4;
}
Message message = 2;
Transaction transaction = 2;
}
message SendMessageResponse {
message SendTransactionResponse {
bytes hash = 1;
}

View File

@ -1,4 +1,4 @@
mkdir go
protoc -I . --go_out=plugins=grpc:go bg/api/common.proto
protoc -I . --go_out=plugins=grpc:go bg/api/tx_ledger.proto
protoc -I . --go_out=plugins=grpc:go bg/api/ac_chain.proto
mkdir gen\go
protoc -I . --go_out=plugins=grpc:gen/go bdchain/api/common.proto
protoc -I . --go_out=plugins=grpc:gen/go bdchain/api/tx_ledger.proto
protoc -I . --go_out=plugins=grpc:gen/go bdchain/api/ac_chain.proto

9
gen.sh
View File

@ -1,4 +1,5 @@
mkdir go
protoc -I . --go_out=plugins=grpc:go bg/api/common.proto
protoc -I . --go_out=plugins=grpc:go bg/api/tx_ledger.proto
protoc -I . --go_out=plugins=grpc:go bg/api/ac_chain.proto
#!/usr/bin/env bash
mkdir -p gen/go
protoc -I . --go_out=plugins=grpc:gen/go bdchain/api/common.proto
protoc -I . --go_out=plugins=grpc:gen/go bdchain/api/tx_ledger.proto
protoc -I . --go_out=plugins=grpc:gen/go bdchain/api/ac_chain.proto