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": { "protobufAny": {
"type": "object", "type": "object",
"properties": { "properties": {
"typeUrl": { "@type": {
"type": "string" "type": "string"
},
"value": {
"type": "string",
"format": "byte"
} }
} },
"additionalProperties": {}
}, },
"rpcStatus": { "rpcStatus": {
"type": "object", "type": "object",

View File

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

View File

@ -101,7 +101,13 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "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": { "apiSendTransactionRequestTransaction": {
"type": "object", "type": "object",
"properties": { "properties": {
"type": { "type": {
"$ref": "#/definitions/apiTransactionType" "$ref": "#/definitions/apiTransactionType",
"title": "事务类型目前仅支持通用数据记录即type为RECORD (0)"
}, },
"from": { "from": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "任意20字节的地址用于区分使用同一节点的事务发起者"
}, },
"nonce": { "nonce": {
"type": "string", "type": "string",
"format": "uint64" "format": "uint64",
"title": "正整数同一from每个nonce应只使用一次防止重复的事务可以每次发送事务+1"
}, },
"to": { "to": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "对于通用数据记录不需传递,无意义"
}, },
"data": { "data": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "事务数据内容,字节数组"
} }
} }
}, },
@ -199,19 +197,17 @@
"CONTRACT_STATUS" "CONTRACT_STATUS"
], ],
"default": "RECORD", "default": "RECORD",
"description": "- RECORD: 通用数据记录\n - MESSAGE: 消息\n - CONTRACT_CREATION: 合约创建\n - CONTRACT_INVOCATION: 合约调用\n - CONTRACT_STATUS: 合约状态",
"title": "事务类型" "title": "事务类型"
}, },
"protobufAny": { "protobufAny": {
"type": "object", "type": "object",
"properties": { "properties": {
"typeUrl": { "@type": {
"type": "string" "type": "string"
},
"value": {
"type": "string",
"format": "byte"
} }
} },
"additionalProperties": {}
}, },
"rpcStatus": { "rpcStatus": {
"type": "object", "type": "object",

View File

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

View File

@ -37,12 +37,14 @@
"parameters": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
}, },
{ {
"name": "hash", "name": "hash",
"description": "区块哈希",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "string", "type": "string",
@ -50,6 +52,7 @@
}, },
{ {
"name": "fullTransactions", "name": "fullTransactions",
"description": "是否返回完整事务列表,而不是事务哈希列表",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "boolean" "type": "boolean"
@ -81,12 +84,14 @@
"parameters": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
}, },
{ {
"name": "blockHash", "name": "blockHash",
"description": "事务所属区块哈希",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "string", "type": "string",
@ -94,6 +99,7 @@
}, },
{ {
"name": "index", "name": "index",
"description": "事务在区块中的位置",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "integer", "type": "integer",
@ -126,6 +132,7 @@
"parameters": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
@ -135,7 +142,30 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "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": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
@ -174,7 +205,30 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "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": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
}, },
{ {
"name": "offset", "name": "offset",
"description": "起始值",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "string", "type": "string",
@ -217,6 +273,7 @@
}, },
{ {
"name": "count", "name": "count",
"description": "查询区块数量",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "string", "type": "string",
@ -224,6 +281,7 @@
}, },
{ {
"name": "includeTransactions", "name": "includeTransactions",
"description": "包含事务信息详细程度\n\n - NONE: 不包含事务数据\n - HASH: 包含事务哈希列表\n - FULL: 包含完整事务列表",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "string", "type": "string",
@ -261,12 +319,14 @@
"parameters": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
}, },
{ {
"name": "hash", "name": "hash",
"description": "事务哈希",
"in": "query", "in": "query",
"required": false, "required": false,
"type": "string", "type": "string",
@ -299,6 +359,7 @@
"parameters": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
@ -308,7 +369,26 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "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": [ "parameters": [
{ {
"name": "ledger", "name": "ledger",
"description": "账本名称",
"in": "path", "in": "path",
"required": true, "required": true,
"type": "string" "type": "string"
@ -347,7 +428,26 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "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": { "properties": {
"hash": { "hash": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "区块的哈希,当区块处于待确认状态时为`null`"
}, },
"creator": { "creator": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "产块者账户地址"
}, },
"nonce": { "nonce": {
"type": "string", "type": "string",
"format": "uint64" "format": "uint64",
"title": "这个区块之前产块者产生的区块数量"
}, },
"parentHashes": { "parentHashes": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"format": "byte" "format": "byte"
} },
"title": "父区块的哈希"
}, },
"witnesses": { "witnesses": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"format": "byte" "format": "byte"
} },
"title": "见证者账户地址"
}, },
"timestamp": { "timestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "区块产生时的 UNIX 时间戳,单位为秒"
}, },
"size": { "size": {
"type": "string", "type": "string",
"format": "uint64" "format": "uint64",
"title": "区块大小的字节数"
}, },
"transactionCount": { "transactionCount": {
"type": "integer", "type": "integer",
"format": "int64" "format": "int64",
"title": "区块包含的事务数量"
}, },
"transactionsRoot": { "transactionsRoot": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "区块的事务默克尔树根"
}, },
"transactions": { "transactions": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/bdledgerapiTransaction" "$ref": "#/definitions/bdledgerapiTransaction"
} },
"title": "事务对象的数组,或为空"
}, },
"transactionHashes": { "transactionHashes": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"format": "byte" "format": "byte"
} },
"title": "20字节的事务哈希的数组或为空"
},
"creatorSignature": {
"type": "string",
"format": "byte",
"title": "产块者签名"
},
"witnessSignatures": {
"type": "string",
"format": "byte",
"title": "见证者签名"
} }
} }
}, },
@ -432,45 +553,23 @@
}, },
"title": "*\n暂不支持" "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": { "apiCountBlocksResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"count": { "count": {
"type": "string", "type": "string",
"format": "uint64" "format": "uint64",
"title": "区块数量"
}, },
"startTimestamp": { "startTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围开始时间戳"
}, },
"endTimestamp": { "endTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围结束时间戳"
} }
} }
}, },
@ -479,15 +578,18 @@
"properties": { "properties": {
"count": { "count": {
"type": "string", "type": "string",
"format": "uint64" "format": "uint64",
"title": "事务数量"
}, },
"startTimestamp": { "startTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围开始时间戳"
}, },
"endTimestamp": { "endTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围结束时间戳"
} }
} }
}, },
@ -495,7 +597,8 @@
"type": "object", "type": "object",
"properties": { "properties": {
"block": { "block": {
"$ref": "#/definitions/apiBlock" "$ref": "#/definitions/apiBlock",
"title": "区块信息"
} }
} }
}, },
@ -506,15 +609,18 @@
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/apiBlock" "$ref": "#/definitions/apiBlock"
} },
"title": "区块列表"
}, },
"startTimestamp": { "startTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围开始时间戳"
}, },
"endTimestamp": { "endTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围结束时间戳"
} }
} }
}, },
@ -522,7 +628,8 @@
"type": "object", "type": "object",
"properties": { "properties": {
"transaction": { "transaction": {
"$ref": "#/definitions/bdledgerapiTransaction" "$ref": "#/definitions/bdledgerapiTransaction",
"title": "事务信息"
} }
} }
}, },
@ -530,7 +637,8 @@
"type": "object", "type": "object",
"properties": { "properties": {
"transaction": { "transaction": {
"$ref": "#/definitions/bdledgerapiTransaction" "$ref": "#/definitions/bdledgerapiTransaction",
"title": "事务信息"
} }
} }
}, },
@ -541,15 +649,18 @@
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/bdledgerapiTransaction" "$ref": "#/definitions/bdledgerapiTransaction"
} },
"title": "事务列表"
}, },
"startTimestamp": { "startTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围开始时间戳"
}, },
"endTimestamp": { "endTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "本次查询有效的查询范围结束时间戳"
} }
} }
}, },
@ -561,6 +672,7 @@
"FULL" "FULL"
], ],
"default": "NONE", "default": "NONE",
"description": "- NONE: 不包含事务数据\n - HASH: 包含事务哈希列表\n - FULL: 包含完整事务列表",
"title": "*\n包含事务信息详细程度" "title": "*\n包含事务信息详细程度"
}, },
"apiTransactionFilter": { "apiTransactionFilter": {
@ -595,93 +707,81 @@
"CONTRACT_STATUS" "CONTRACT_STATUS"
], ],
"default": "RECORD", "default": "RECORD",
"description": "- RECORD: 通用数据记录\n - MESSAGE: 消息\n - CONTRACT_CREATION: 合约创建\n - CONTRACT_INVOCATION: 合约调用\n - CONTRACT_STATUS: 合约状态",
"title": "事务类型" "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": { "bdledgerapiTransaction": {
"type": "object", "type": "object",
"properties": { "properties": {
"blockHash": { "blockHash": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "事务所在的区块的哈希,当事务处于待确认状态时为`null`"
}, },
"blockTimestamp": { "blockTimestamp": {
"type": "string", "type": "string",
"format": "int64" "format": "int64",
"title": "事务所在的区块产生时的 UNIX 时间戳,单位为秒"
}, },
"index": { "index": {
"type": "integer", "type": "integer",
"format": "int64" "format": "int64",
"title": "事务在区块中的位置 index当事务处于待确认状态时为`null`"
}, },
"hash": { "hash": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "事务的哈希"
}, },
"type": { "type": {
"$ref": "#/definitions/apiTransactionType" "$ref": "#/definitions/apiTransactionType",
"title": "事务类型"
}, },
"from": { "from": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "发送账户地址"
}, },
"nonce": { "nonce": {
"type": "string", "type": "string",
"format": "uint64" "format": "uint64",
"title": "这条事务之前发送者所发送的事务数量"
}, },
"to": { "to": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "接收账户地址,或者调用的合约地址,或者`null`如为合约创建"
}, },
"data": { "data": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "数据或合约代码"
}, },
"v": { "v": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "ECDSA recovery id"
}, },
"r": { "r": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "ECDSA signature r"
}, },
"s": { "s": {
"type": "string", "type": "string",
"format": "byte" "format": "byte",
"title": "ECDSA signature s"
} }
} }
}, },
"protobufAny": { "protobufAny": {
"type": "object", "type": "object",
"properties": { "properties": {
"typeUrl": { "@type": {
"type": "string" "type": "string"
},
"value": {
"type": "string",
"format": "byte"
} }
} },
"additionalProperties": {}
}, },
"rpcStatus": { "rpcStatus": {
"type": "object", "type": "object",

View File

@ -10,19 +10,19 @@ See [API documentation](..\docs\apis.md)
##### Installling tools ##### 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 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 ```shell
GIT_TAG="v1.27.1" GIT_TAG="v1.28.1"
go get -d -u google.golang.org/protobuf/cmd/protoc-gen-go 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 git -C "$(go env GOPATH)"/src/google.golang.org/protobuf checkout $GIT_TAG
go install google.golang.org/protobuf/cmd/protoc-gen-go 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 ```shell
go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc 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 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 For generating validators
install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators): 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; // bytes transactions_root = 9; //
repeated Transaction transactions = 10; // repeated Transaction transactions = 10; //
repeated bytes transaction_hashes = 11; // 20 repeated bytes transaction_hashes = 11; // 20
bytes creator_signature = 12; //
bytes witness_signatures = 13; //
} }
message Contract { message Contract {