feat: add Block.creator_signature and Block.witness_signatures

This commit is contained in:
Nex Zhu 2022-11-14 01:22:04 +08:00
parent 94743e9a17
commit ae35d605b1
No known key found for this signature in database
GPG Key ID: 15C6254AD19362B4
7 changed files with 232 additions and 143 deletions

View File

@ -15,14 +15,11 @@
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"@type": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",

View File

@ -15,14 +15,11 @@
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"@type": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",

View File

@ -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",

View File

@ -53,14 +53,11 @@
"protobufAny": {
"type": "object",
"properties": {
"typeUrl": {
"@type": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",

View File

@ -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",

View File

@ -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):

View File

@ -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 {