Restructure project
This commit is contained in:
65
grpc/pb/bdware/bdledger/api/common.proto
Normal file
65
grpc/pb/bdware/bdledger/api/common.proto
Normal file
@@ -0,0 +1,65 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bdware.bdledger.api;
|
||||
|
||||
option go_package = "bdware.org/bdledger/api/grpc/pb";
|
||||
option java_package = "org.bdware.bdledger.api.grpc.pb";
|
||||
|
||||
/* 事务类型 */
|
||||
enum TransactionType {
|
||||
RECORD = 0; // 通用数据记录
|
||||
MESSAGE = 1; // 消息
|
||||
CONTRACT_CREATION = 2; // 合约创建
|
||||
CONTRACT_INVOCATION = 3; // 合约调用
|
||||
CONTRACT_STATUS = 4; // 合约状态
|
||||
}
|
||||
|
||||
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 {
|
||||
bytes hash = 1; // 区块的哈希,当区块处于待确认状态时为`null`
|
||||
repeated bytes parent_hashes = 2; // 父区块的哈希
|
||||
repeated bytes witnesses = 3; // 见证者账户地址
|
||||
int64 timestamp = 4; // 区块产生时的 UNIX 时间戳,单位为秒
|
||||
uint64 size = 5; // 区块大小的字节数
|
||||
uint32 transaction_count = 6; // 区块包含的事务数量
|
||||
bytes transactions_root = 7; // 区块的事务默克尔树根
|
||||
repeated Transaction transactions = 8; // 事务对象的数组,或为空
|
||||
repeated bytes transaction_hashes = 9; // 20字节的交易哈希的数组,或为空
|
||||
}
|
||||
|
||||
message Contract {
|
||||
bytes contractName = 1; //合约名称
|
||||
uint32 randomNum = 2; //合约执行的节点数量
|
||||
bytes operation = 3; //合约方法
|
||||
bytes arg = 4; //合约方法参数
|
||||
bytes path = 5; //合约文件路径(合约在IDE工程的相对路径)
|
||||
bytes content = 6; //合约内容(可为合约文件相对路径/合约脚本)
|
||||
bytes pubkey = 7; //用户公钥
|
||||
|
||||
enum ContractUnitRequestType{
|
||||
START = 0;
|
||||
STOP = 1;
|
||||
EXECUTE = 2;
|
||||
REPLY = 3;
|
||||
REQUEST = 4;
|
||||
PREPREPARE = 5;
|
||||
PREPARE = 6;
|
||||
COMMIT = 7;
|
||||
ADDPEER = 8;
|
||||
DROPPEER = 9;
|
||||
STATESYNC = 10;
|
||||
}
|
||||
}
|
||||
26
grpc/pb/bdware/bdledger/api/error_details.proto
Normal file
26
grpc/pb/bdware/bdledger/api/error_details.proto
Normal file
@@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bdware.bdledger.api;
|
||||
|
||||
option go_package = "bdware.org/bdledger/api/grpc/pb";
|
||||
option java_package = "org.bdware.bdledger.api.grpc.pb";
|
||||
|
||||
// InvalidArgument indicates client specified an invalid argument.
|
||||
// Note that this differs from FailedPrecondition. It indicates arguments
|
||||
// that are problematic regardless of the state of the system
|
||||
// (e.g., a malformed file name).
|
||||
message InvalidArgument {
|
||||
// A message type used to describe a single invalid field.
|
||||
message FieldViolation {
|
||||
// A path leading to a field in the request body. The value will be a
|
||||
// sequence of dot-separated identifiers that identify a protocol buffer
|
||||
// field. E.g., "field_violations.field" would identify this field.
|
||||
string field = 1;
|
||||
|
||||
// A description of why the request element is bad.
|
||||
string description = 2;
|
||||
}
|
||||
|
||||
// Describes all violations in a client request.
|
||||
repeated FieldViolation field_violations = 1;
|
||||
}
|
||||
40
grpc/pb/bdware/bdledger/api/ledger.proto
Normal file
40
grpc/pb/bdware/bdledger/api/ledger.proto
Normal file
@@ -0,0 +1,40 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bdware.bdledger.api;
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "bdware/bdledger/api/common.proto";
|
||||
|
||||
option go_package = "bdware.org/bdledger/api/grpc/pb";
|
||||
option java_package = "org.bdware.bdledger.api.grpc.pb";
|
||||
|
||||
service Ledger {
|
||||
rpc CreateLedger (CreateLedgerRequest) returns (CreateLedgerResponse);
|
||||
rpc GetLedgers (google.protobuf.Empty) returns (GetLedgersResponse);
|
||||
rpc SendTransaction (SendTransactionRequest) returns (SendTransactionResponse);
|
||||
}
|
||||
|
||||
message CreateLedgerRequest {
|
||||
string name = 1;
|
||||
}
|
||||
message CreateLedgerResponse {
|
||||
bool ok = 1;
|
||||
}
|
||||
|
||||
message GetLedgersResponse {
|
||||
repeated string ledgers = 1;
|
||||
}
|
||||
|
||||
message SendTransactionRequest {
|
||||
string ledger = 1;
|
||||
message Transaction {
|
||||
TransactionType type = 1;
|
||||
bytes from = 2;
|
||||
bytes to = 3;
|
||||
bytes data = 4;
|
||||
}
|
||||
Transaction transaction = 2;
|
||||
}
|
||||
message SendTransactionResponse {
|
||||
bytes hash = 1;
|
||||
}
|
||||
16
grpc/pb/bdware/bdledger/api/node.proto
Normal file
16
grpc/pb/bdware/bdledger/api/node.proto
Normal file
@@ -0,0 +1,16 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bdware.bdledger.api;
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
option go_package = "bdware.org/bdledger/api/grpc/pb";
|
||||
option java_package = "org.bdware.bdledger.api.grpc.pb";
|
||||
|
||||
service Node {
|
||||
rpc ClientVersion (google.protobuf.Empty) returns (ClientVersionResponse);
|
||||
}
|
||||
|
||||
message ClientVersionResponse {
|
||||
string version = 1; // 节点客户端版本
|
||||
}
|
||||
97
grpc/pb/bdware/bdledger/api/query.proto
Normal file
97
grpc/pb/bdware/bdledger/api/query.proto
Normal file
@@ -0,0 +1,97 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package bdware.bdledger.api;
|
||||
|
||||
import "bdware/bdledger/api/common.proto";
|
||||
|
||||
option go_package = "bdware.org/bdledger/api/grpc/pb";
|
||||
option java_package = "org.bdware.bdledger.api.grpc.pb";
|
||||
|
||||
service Query {
|
||||
rpc GetBlockByHash (GetBlockByHashRequest) returns (GetBlockByHashResponse);
|
||||
rpc GetBlocks (BlocksRequest) returns (GetBlocksResponse); // start_timestamp is required
|
||||
rpc CountBlocks (BlocksRequest) returns (CountBlocksResponse);
|
||||
rpc GetTransactionByHash (GetTransactionByHashRequest) returns (GetTransactionByHashResponse);
|
||||
rpc GetTransactionByBlockHashAndIndex (GetTransactionByBlockHashAndIndexRequest) returns (GetTransactionByBlockHashAndIndexResponse);
|
||||
rpc GetTransactions (TransactionsRequest) returns (GetTransactionsResponse);
|
||||
rpc CountTransactions (TransactionsRequest) returns (CountTransactionsResponse);
|
||||
}
|
||||
|
||||
message BlockFilter {
|
||||
bytes hash = 1;
|
||||
int64 timestamp = 2;
|
||||
}
|
||||
|
||||
// repeated Transaction/BlockFilters are combined by "&&"(and) operator;
|
||||
message TransactionFilter {
|
||||
bytes hash = 1;
|
||||
bytes from = 2;
|
||||
bytes to = 3;
|
||||
bytes timestamp = 4;
|
||||
}
|
||||
|
||||
message GetBlockByHashRequest {
|
||||
string ledger = 1;
|
||||
bytes hash = 2;
|
||||
bool full_transactions = 3;
|
||||
}
|
||||
message GetBlockByHashResponse {
|
||||
Block block = 1;
|
||||
}
|
||||
|
||||
message BlocksRequest {
|
||||
string ledger = 1;
|
||||
int64 start_timestamp = 2;
|
||||
int64 end_timestamp = 3;
|
||||
repeated BlockFilter filters = 4;
|
||||
enum IncludeTransactions {
|
||||
NONE = 0; // 不包含交易数据
|
||||
HASH = 1; // 包含交易哈希列表
|
||||
FULL = 2; // 包含完整交易列表
|
||||
}
|
||||
IncludeTransactions include_transactions = 5;
|
||||
}
|
||||
message GetBlocksResponse {
|
||||
repeated Block blocks = 1;
|
||||
int64 start_timestamp = 2;
|
||||
int64 end_timestamp = 3;
|
||||
}
|
||||
message CountBlocksResponse {
|
||||
uint64 count = 1;
|
||||
int64 start_timestamp = 2;
|
||||
int64 end_timestamp = 3;
|
||||
}
|
||||
|
||||
message GetTransactionByHashRequest {
|
||||
string ledger = 1;
|
||||
bytes hash = 2;
|
||||
}
|
||||
message GetTransactionByHashResponse {
|
||||
Transaction transaction = 1;
|
||||
}
|
||||
|
||||
message GetTransactionByBlockHashAndIndexRequest {
|
||||
string ledger = 1;
|
||||
bytes block_hash = 2;
|
||||
uint32 index = 3;
|
||||
}
|
||||
message GetTransactionByBlockHashAndIndexResponse {
|
||||
Transaction transaction = 1;
|
||||
}
|
||||
|
||||
message TransactionsRequest {
|
||||
string ledger = 1;
|
||||
int64 start_timestamp = 2; // required
|
||||
int64 end_timestamp = 3;
|
||||
repeated TransactionFilter filters = 4;
|
||||
}
|
||||
message GetTransactionsResponse {
|
||||
repeated Transaction transactions = 1;
|
||||
int64 start_timestamp = 2;
|
||||
int64 end_timestamp = 3;
|
||||
}
|
||||
message CountTransactionsResponse {
|
||||
uint64 count = 1;
|
||||
int64 start_timestamp = 2;
|
||||
int64 end_timestamp = 3;
|
||||
}
|
||||
52
grpc/pb/google/protobuf/empty.proto
Normal file
52
grpc/pb/google/protobuf/empty.proto
Normal file
@@ -0,0 +1,52 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.protobuf;
|
||||
|
||||
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
|
||||
option go_package = "github.com/golang/protobuf/ptypes/empty";
|
||||
option java_package = "com.google.protobuf";
|
||||
option java_outer_classname = "EmptyProto";
|
||||
option java_multiple_files = true;
|
||||
option objc_class_prefix = "GPB";
|
||||
option cc_enable_arenas = true;
|
||||
|
||||
// A generic empty message that you can re-use to avoid defining duplicated
|
||||
// empty messages in your APIs. A typical example is to use it as the request
|
||||
// or the response type of an API method. For instance:
|
||||
//
|
||||
// service Foo {
|
||||
// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
// }
|
||||
//
|
||||
// The JSON representation for `Empty` is empty JSON object `{}`.
|
||||
message Empty {}
|
||||
Reference in New Issue
Block a user