diff --git a/docs/openapiv2/bdware/bdledger/api/common.swagger.json b/docs/openapiv2/bdware/bdledger/api/common.swagger.json index 3a72efa..cbb76fc 100644 --- a/docs/openapiv2/bdware/bdledger/api/common.swagger.json +++ b/docs/openapiv2/bdware/bdledger/api/common.swagger.json @@ -15,14 +15,11 @@ "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/docs/openapiv2/bdware/bdledger/api/error_details.swagger.json b/docs/openapiv2/bdware/bdledger/api/error_details.swagger.json index 48033c8..9b051da 100644 --- a/docs/openapiv2/bdware/bdledger/api/error_details.swagger.json +++ b/docs/openapiv2/bdware/bdledger/api/error_details.swagger.json @@ -15,14 +15,11 @@ "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/docs/openapiv2/bdware/bdledger/api/ledger.swagger.json b/docs/openapiv2/bdware/bdledger/api/ledger.swagger.json index c783591..7d63ef1 100644 --- a/docs/openapiv2/bdware/bdledger/api/ledger.swagger.json +++ b/docs/openapiv2/bdware/bdledger/api/ledger.swagger.json @@ -101,7 +101,13 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/apiSendTransactionRequest" + "type": "object", + "properties": { + "transaction": { + "$ref": "#/definitions/apiSendTransactionRequestTransaction", + "title": "Transaction info\n事务信息" + } + } } } ], @@ -142,40 +148,32 @@ } } }, - "apiSendTransactionRequest": { - "type": "object", - "properties": { - "ledger": { - "type": "string", - "title": "Ledger name\n账本名称" - }, - "transaction": { - "$ref": "#/definitions/apiSendTransactionRequestTransaction", - "title": "Transaction info\n事务信息" - } - } - }, "apiSendTransactionRequestTransaction": { "type": "object", "properties": { "type": { - "$ref": "#/definitions/apiTransactionType" + "$ref": "#/definitions/apiTransactionType", + "title": "事务类型,目前仅支持通用数据记录,即type为RECORD (0)" }, "from": { "type": "string", - "format": "byte" + "format": "byte", + "title": "任意20字节的地址,用于区分使用同一节点的事务发起者" }, "nonce": { "type": "string", - "format": "uint64" + "format": "uint64", + "title": "正整数,同一from每个nonce应只使用一次,防止重复的事务(可以每次发送事务+1)" }, "to": { "type": "string", - "format": "byte" + "format": "byte", + "title": "对于通用数据记录不需传递,无意义" }, "data": { "type": "string", - "format": "byte" + "format": "byte", + "title": "事务数据内容,字节数组" } } }, @@ -199,19 +197,17 @@ "CONTRACT_STATUS" ], "default": "RECORD", + "description": "- RECORD: 通用数据记录\n - MESSAGE: 消息\n - CONTRACT_CREATION: 合约创建\n - CONTRACT_INVOCATION: 合约调用\n - CONTRACT_STATUS: 合约状态", "title": "事务类型" }, "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/docs/openapiv2/bdware/bdledger/api/node.swagger.json b/docs/openapiv2/bdware/bdledger/api/node.swagger.json index 05afed3..9cf3775 100644 --- a/docs/openapiv2/bdware/bdledger/api/node.swagger.json +++ b/docs/openapiv2/bdware/bdledger/api/node.swagger.json @@ -53,14 +53,11 @@ "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/docs/openapiv2/bdware/bdledger/api/query.swagger.json b/docs/openapiv2/bdware/bdledger/api/query.swagger.json index bba4761..aa402d5 100644 --- a/docs/openapiv2/bdware/bdledger/api/query.swagger.json +++ b/docs/openapiv2/bdware/bdledger/api/query.swagger.json @@ -37,12 +37,14 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" }, { "name": "hash", + "description": "区块哈希", "in": "query", "required": false, "type": "string", @@ -50,6 +52,7 @@ }, { "name": "fullTransactions", + "description": "是否返回完整事务列表,而不是事务哈希列表", "in": "query", "required": false, "type": "boolean" @@ -81,12 +84,14 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" }, { "name": "blockHash", + "description": "事务所属区块哈希", "in": "query", "required": false, "type": "string", @@ -94,6 +99,7 @@ }, { "name": "index", + "description": "事务在区块中的位置", "in": "query", "required": false, "type": "integer", @@ -126,6 +132,7 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" @@ -135,7 +142,30 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/apiBlocksRequest" + "type": "object", + "properties": { + "startTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围开始时间戳" + }, + "endTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围结束时间戳" + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/apiBlockFilter" + }, + "title": "暂不支持" + }, + "includeTransactions": { + "$ref": "#/definitions/apiIncludeTransactions", + "title": "包含事务信息详细程度" + } + } } } ], @@ -165,6 +195,7 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" @@ -174,7 +205,30 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/apiBlocksRequest" + "type": "object", + "properties": { + "startTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围开始时间戳" + }, + "endTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围结束时间戳" + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/apiBlockFilter" + }, + "title": "暂不支持" + }, + "includeTransactions": { + "$ref": "#/definitions/apiIncludeTransactions", + "title": "包含事务信息详细程度" + } + } } } ], @@ -204,12 +258,14 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" }, { "name": "offset", + "description": "起始值", "in": "query", "required": false, "type": "string", @@ -217,6 +273,7 @@ }, { "name": "count", + "description": "查询区块数量", "in": "query", "required": false, "type": "string", @@ -224,6 +281,7 @@ }, { "name": "includeTransactions", + "description": "包含事务信息详细程度\n\n - NONE: 不包含事务数据\n - HASH: 包含事务哈希列表\n - FULL: 包含完整事务列表", "in": "query", "required": false, "type": "string", @@ -261,12 +319,14 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" }, { "name": "hash", + "description": "事务哈希", "in": "query", "required": false, "type": "string", @@ -299,6 +359,7 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" @@ -308,7 +369,26 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/apiTransactionsRequest" + "type": "object", + "properties": { + "startTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围开始时间戳" + }, + "endTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围结束时间戳" + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/apiTransactionFilter" + }, + "title": "暂不支持" + } + } } } ], @@ -338,6 +418,7 @@ "parameters": [ { "name": "ledger", + "description": "账本名称", "in": "path", "required": true, "type": "string" @@ -347,7 +428,26 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/apiTransactionsRequest" + "type": "object", + "properties": { + "startTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围开始时间戳" + }, + "endTimestamp": { + "type": "string", + "format": "int64", + "title": "查询范围结束时间戳" + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/apiTransactionFilter" + }, + "title": "暂不支持" + } + } } } ], @@ -363,58 +463,79 @@ "properties": { "hash": { "type": "string", - "format": "byte" + "format": "byte", + "title": "区块的哈希,当区块处于待确认状态时为`null`" }, "creator": { "type": "string", - "format": "byte" + "format": "byte", + "title": "产块者账户地址" }, "nonce": { "type": "string", - "format": "uint64" + "format": "uint64", + "title": "这个区块之前产块者产生的区块数量" }, "parentHashes": { "type": "array", "items": { "type": "string", "format": "byte" - } + }, + "title": "父区块的哈希" }, "witnesses": { "type": "array", "items": { "type": "string", "format": "byte" - } + }, + "title": "见证者账户地址" }, "timestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "区块产生时的 UNIX 时间戳,单位为秒" }, "size": { "type": "string", - "format": "uint64" + "format": "uint64", + "title": "区块大小的字节数" }, "transactionCount": { "type": "integer", - "format": "int64" + "format": "int64", + "title": "区块包含的事务数量" }, "transactionsRoot": { "type": "string", - "format": "byte" + "format": "byte", + "title": "区块的事务默克尔树根" }, "transactions": { "type": "array", "items": { "$ref": "#/definitions/bdledgerapiTransaction" - } + }, + "title": "事务对象的数组,或为空" }, "transactionHashes": { "type": "array", "items": { "type": "string", "format": "byte" - } + }, + "title": "20字节的事务哈希的数组,或为空" + }, + "creatorSignature": { + "type": "string", + "format": "byte", + "title": "产块者签名" + }, + "witnessSignatures": { + "type": "string", + "format": "byte", + "title": "见证者签名" } } }, @@ -432,45 +553,23 @@ }, "title": "*\n暂不支持" }, - "apiBlocksRequest": { - "type": "object", - "properties": { - "ledger": { - "type": "string" - }, - "startTimestamp": { - "type": "string", - "format": "int64" - }, - "endTimestamp": { - "type": "string", - "format": "int64" - }, - "filters": { - "type": "array", - "items": { - "$ref": "#/definitions/apiBlockFilter" - } - }, - "includeTransactions": { - "$ref": "#/definitions/apiIncludeTransactions" - } - } - }, "apiCountBlocksResponse": { "type": "object", "properties": { "count": { "type": "string", - "format": "uint64" + "format": "uint64", + "title": "区块数量" }, "startTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围开始时间戳" }, "endTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围结束时间戳" } } }, @@ -479,15 +578,18 @@ "properties": { "count": { "type": "string", - "format": "uint64" + "format": "uint64", + "title": "事务数量" }, "startTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围开始时间戳" }, "endTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围结束时间戳" } } }, @@ -495,7 +597,8 @@ "type": "object", "properties": { "block": { - "$ref": "#/definitions/apiBlock" + "$ref": "#/definitions/apiBlock", + "title": "区块信息" } } }, @@ -506,15 +609,18 @@ "type": "array", "items": { "$ref": "#/definitions/apiBlock" - } + }, + "title": "区块列表" }, "startTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围开始时间戳" }, "endTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围结束时间戳" } } }, @@ -522,7 +628,8 @@ "type": "object", "properties": { "transaction": { - "$ref": "#/definitions/bdledgerapiTransaction" + "$ref": "#/definitions/bdledgerapiTransaction", + "title": "事务信息" } } }, @@ -530,7 +637,8 @@ "type": "object", "properties": { "transaction": { - "$ref": "#/definitions/bdledgerapiTransaction" + "$ref": "#/definitions/bdledgerapiTransaction", + "title": "事务信息" } } }, @@ -541,15 +649,18 @@ "type": "array", "items": { "$ref": "#/definitions/bdledgerapiTransaction" - } + }, + "title": "事务列表" }, "startTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围开始时间戳" }, "endTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "本次查询有效的查询范围结束时间戳" } } }, @@ -561,6 +672,7 @@ "FULL" ], "default": "NONE", + "description": "- NONE: 不包含事务数据\n - HASH: 包含事务哈希列表\n - FULL: 包含完整事务列表", "title": "*\n包含事务信息详细程度" }, "apiTransactionFilter": { @@ -595,93 +707,81 @@ "CONTRACT_STATUS" ], "default": "RECORD", + "description": "- RECORD: 通用数据记录\n - MESSAGE: 消息\n - CONTRACT_CREATION: 合约创建\n - CONTRACT_INVOCATION: 合约调用\n - CONTRACT_STATUS: 合约状态", "title": "事务类型" }, - "apiTransactionsRequest": { - "type": "object", - "properties": { - "ledger": { - "type": "string" - }, - "startTimestamp": { - "type": "string", - "format": "int64" - }, - "endTimestamp": { - "type": "string", - "format": "int64" - }, - "filters": { - "type": "array", - "items": { - "$ref": "#/definitions/apiTransactionFilter" - } - } - } - }, "bdledgerapiTransaction": { "type": "object", "properties": { "blockHash": { "type": "string", - "format": "byte" + "format": "byte", + "title": "事务所在的区块的哈希,当事务处于待确认状态时为`null`" }, "blockTimestamp": { "type": "string", - "format": "int64" + "format": "int64", + "title": "事务所在的区块产生时的 UNIX 时间戳,单位为秒" }, "index": { "type": "integer", - "format": "int64" + "format": "int64", + "title": "事务在区块中的位置 index,当事务处于待确认状态时为`null`" }, "hash": { "type": "string", - "format": "byte" + "format": "byte", + "title": "事务的哈希" }, "type": { - "$ref": "#/definitions/apiTransactionType" + "$ref": "#/definitions/apiTransactionType", + "title": "事务类型" }, "from": { "type": "string", - "format": "byte" + "format": "byte", + "title": "发送账户地址" }, "nonce": { "type": "string", - "format": "uint64" + "format": "uint64", + "title": "这条事务之前发送者所发送的事务数量" }, "to": { "type": "string", - "format": "byte" + "format": "byte", + "title": "接收账户地址,或者调用的合约地址,或者`null`如为合约创建" }, "data": { "type": "string", - "format": "byte" + "format": "byte", + "title": "数据或合约代码" }, "v": { "type": "string", - "format": "byte" + "format": "byte", + "title": "ECDSA recovery id" }, "r": { "type": "string", - "format": "byte" + "format": "byte", + "title": "ECDSA signature r" }, "s": { "type": "string", - "format": "byte" + "format": "byte", + "title": "ECDSA signature s" } } }, "protobufAny": { "type": "object", "properties": { - "typeUrl": { + "@type": { "type": "string" - }, - "value": { - "type": "string", - "format": "byte" } - } + }, + "additionalProperties": {} }, "rpcStatus": { "type": "object", diff --git a/grpc/README.md b/grpc/README.md index a8f0865..e9aac97 100644 --- a/grpc/README.md +++ b/grpc/README.md @@ -10,19 +10,19 @@ See [API documentation](..\docs\apis.md) ##### Installling tools -Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.17.3-*)+ for +Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.21.9-*)+ for your platform and add `protoc` to `PATH` environment variable -For generating Go code, install `protoc-gen-go` (v1.27.1+): +For generating Go code, install `protoc-gen-go` (v1.28.1+): ```shell -GIT_TAG="v1.27.1" +GIT_TAG="v1.28.1" go get -d -u google.golang.org/protobuf/cmd/protoc-gen-go git -C "$(go env GOPATH)"/src/google.golang.org/protobuf checkout $GIT_TAG go install google.golang.org/protobuf/cmd/protoc-gen-go ``` -Also install `protoc-gen-go-grpc` v1.1.0+: +Also install `protoc-gen-go-grpc` v1.2.0+: ```shell go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc @@ -36,7 +36,7 @@ gobin google.golang.org/grpc/cmd/protoc-gen-go-grpc ``` For generating HTTP JSON APIs with [grpc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/), follow -the [documentation](https://github.com/grpc-ecosystem/grpc-gateway/tree/v2#installation). +the [documentation](https://github.com/grpc-ecosystem/grpc-gateway#installation). For generating validators install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators): diff --git a/grpc/pb/bdware/bdledger/api/common.proto b/grpc/pb/bdware/bdledger/api/common.proto index 143b41a..1b5e447 100644 --- a/grpc/pb/bdware/bdledger/api/common.proto +++ b/grpc/pb/bdware/bdledger/api/common.proto @@ -42,6 +42,8 @@ message Block { bytes transactions_root = 9; // 区块的事务默克尔树根 repeated Transaction transactions = 10; // 事务对象的数组,或为空 repeated bytes transaction_hashes = 11; // 20字节的事务哈希的数组,或为空 + bytes creator_signature = 12; // 产块者签名 + bytes witness_signatures = 13; // 见证者签名 } message Contract {