chore: update gRPC tools

This commit is contained in:
Nex 2021-02-12 21:12:20 +08:00
parent b6ebbaa879
commit 286a348b6f
6 changed files with 3780 additions and 230 deletions

View File

@ -4,20 +4,126 @@
"title": "bdware/bdledger/api/ledger.proto",
"version": "version not set"
},
"tags": [
{
"name": "Ledger"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"paths": {
"/v0/ledgers": {
"get": {
"summary": "*\nGet all ledgers\n查询所有帐本列表",
"operationId": "Ledger_GetLedgers",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiGetLedgersResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"Ledger"
]
},
"post": {
"summary": "*\nCreate a new ledger\n创建一个新账本",
"operationId": "Ledger_CreateLedger",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiCreateLedgerResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/apiCreateLedgerRequest"
}
}
],
"tags": [
"Ledger"
]
}
},
"/v0/ledgers/{ledger}/transactions": {
"post": {
"summary": "*\nSend a new transaction\n发送一个新事务",
"operationId": "Ledger_SendTransaction",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiSendTransactionResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/apiSendTransactionRequest"
}
}
],
"tags": [
"Ledger"
]
}
}
},
"definitions": {
"apiCreateLedgerRequest": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"apiCreateLedgerResponse": {
"type": "object",
"properties": {
"ok": {
"type": "boolean",
"format": "boolean"
"type": "boolean"
}
}
},
@ -32,6 +138,17 @@
}
}
},
"apiSendTransactionRequest": {
"type": "object",
"properties": {
"ledger": {
"type": "string"
},
"transaction": {
"$ref": "#/definitions/apiSendTransactionRequestTransaction"
}
}
},
"apiSendTransactionRequestTransaction": {
"type": "object",
"properties": {

View File

@ -4,13 +4,42 @@
"title": "bdware/bdledger/api/node.proto",
"version": "version not set"
},
"tags": [
{
"name": "Node"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"paths": {
"/v0/node/version": {
"get": {
"summary": "*\nGet BDLedger node version\n查询BDLedger节点版本",
"operationId": "Node_ClientVersion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiClientVersionResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"Node"
]
}
}
},
"definitions": {
"apiClientVersionResponse": {
"type": "object",

View File

@ -4,13 +4,352 @@
"title": "bdware/bdledger/api/query.proto",
"version": "version not set"
},
"tags": [
{
"name": "Query"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"paths": {
"/v0/ledgers/{ledger}/block": {
"get": {
"summary": "*\nGet a block identified by its hash\n查询哈希所指定的区块",
"operationId": "Query_GetBlockByHash",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiGetBlockByHashResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "hash",
"in": "query",
"required": false,
"type": "string",
"format": "byte"
},
{
"name": "fullTransactions",
"in": "query",
"required": false,
"type": "boolean"
}
],
"tags": [
"Query"
]
}
},
"/v0/ledgers/{ledger}/block/transaction": {
"get": {
"summary": "*\nGet a transaction identified by hash of the block it belongs to and its index inside the block\n查询所在区块的哈希与其在区块中的index所指定的事务",
"operationId": "Query_GetTransactionByBlockHashAndIndex",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiGetTransactionByBlockHashAndIndexResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "blockHash",
"in": "query",
"required": false,
"type": "string",
"format": "byte"
},
{
"name": "index",
"in": "query",
"required": false,
"type": "integer",
"format": "int64"
}
],
"tags": [
"Query"
]
}
},
"/v0/ledgers/{ledger}/blocks/count": {
"post": {
"summary": "*\nCount all blocks in a ledger, or blocks in a timestamp range\n查询帐本中的所有区块数量或时间范围内的区块数量\nRequirement: start_timestamp \u003c= end_timestamp\nIf neither 'start_timestamp' nor 'end_timestamp' is specified, then count all blocks in the specified ledger.\nIf only 'end_timestamp' is not specified, then count all blocks with timestamps later than 'start_timestamp'.\nIf only 'start_timestamp' is not specified, then count all blocks with timestamps earlier than 'end_timestamp'.\nIn all cases, 'start_timestamp' will never be earlier than the genesis block's timestamp,\nand 'end_timestamp' will never be later than the current timestamp when the node process the query request.",
"operationId": "Query_CountBlocks",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiCountBlocksResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/apiBlocksRequest"
}
}
],
"tags": [
"Query"
]
}
},
"/v0/ledgers/{ledger}/blocks/query": {
"post": {
"summary": "*\nGet blocks in a timestamp range\n查询时间范围内的区块\nRequirement: start_timestamp \u003c= end_timestamp\nIf neither 'start_timestamp' nor 'end_timestamp' is specified, then 'start_timestamp' will be set to\nthe genesis block's timestamp, and 'end_timestamp' will be set to (start_timestamp + query.maxDuration)\n(query.maxDuration is specified in go-bdledger's config file).\nIf only 'end_timestamp' is not specified, or (end_timestamp - start_timestamp \u003e query.maxDuration),\nthen 'end_timestamp' will be set to (start_timestamp + query.maxDuration).\nIf only 'start_timestamp' is not specified, then 'start_timestamp' will be set to (end_timestamp - query.maxDuration).\nIn all cases, 'start_timestamp' will never be earlier than the genesis block's timestamp,\nand 'end_timestamp' will never be later than the current timestamp when the node process the query request.",
"operationId": "Query_GetBlocks",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiGetBlocksResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/apiBlocksRequest"
}
}
],
"tags": [
"Query"
]
}
},
"/v0/ledgers/{ledger}/blocks/recent": {
"get": {
"summary": "*\nGet recent 'count' blocks (Only support IncludeTransactions=NONE for now)\n查询最新的 'count' 个区块",
"operationId": "Query_GetRecentBlocks",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiGetBlocksResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "count",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "includeTransactions",
"in": "query",
"required": false,
"type": "string",
"enum": [
"NONE",
"HASH",
"FULL"
],
"default": "NONE"
}
],
"tags": [
"Query"
]
}
},
"/v0/ledgers/{ledger}/transaction": {
"get": {
"summary": "*\nGet a transaction identified by its hash\n查询哈希所指定的事务",
"operationId": "Query_GetTransactionByHash",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiGetTransactionByHashResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "hash",
"in": "query",
"required": false,
"type": "string",
"format": "byte"
}
],
"tags": [
"Query"
]
}
},
"/v0/ledgers/{ledger}/transactions/count": {
"post": {
"summary": "*\nCount all transactions in a ledger, or transactions in a timestamp range\n查询帐本中的所有事务数量或时间范围内的事务数量\n'start_timestamp' and 'end_timestamp' follow the same requirements and rules as in 'CountBlocks'.",
"operationId": "Query_CountTransactions",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiCountTransactionsResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/apiTransactionsRequest"
}
}
],
"tags": [
"Query"
]
}
},
"/v0/ledgers/{ledger}/transactions/query": {
"post": {
"summary": "*\nGet transactions in a timestamp range\n查询时间范围内的事务\n'start_timestamp' and 'end_timestamp' follow the same requirements and rules as in 'GetBlocks'.",
"operationId": "Query_GetTransactions",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/apiGetTransactionsResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "ledger",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/apiTransactionsRequest"
}
}
],
"tags": [
"Query"
]
}
}
},
"definitions": {
"apiBlock": {
"type": "object",
@ -85,6 +424,31 @@
}
}
},
"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": {
@ -224,6 +588,28 @@
"default": "RECORD",
"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": {

View File

@ -10,7 +10,7 @@ See [API documentation](..\docs\apis.md)
##### Installling tools
Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.13.0-*) for your platform and add `protoc` to `PATH` environment variable
Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-3.15.0-*) for your platform and add `protoc` to `PATH` environment variable
For generating Go code, install `protoc-gen-go` (v1.4.3):
```bash
@ -33,6 +33,11 @@ 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).
For generating validators install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators):
```bash
go get github.com/mwitkow/go-proto-validators/protoc-gen-govalidators
```
For generating Java code: From `bdledger-sdk-java` run `gradle generateProto`
For generating Node.js code (and TypeScript definitions), install Node.js then run:
@ -58,7 +63,7 @@ References:
Run:
```bash
./scripts/gen [-a, --async] [go] [gohttp] [nodejs] [ts] [docs]
./scripts/gen [-a, --async] [go] [gohttp] [nodejs] [docs]
```
Use `-a` or `--async` to speed up generation by asynchronously and concurrently generating all code and documentation (script will exit without waiting for completion)
@ -70,3 +75,4 @@ Install Go then run:
go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
./scripts/gen [-a, --async] docs
```

3454
grpc/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
"Node.js"
],
"devDependencies": {
"grpc-tools": "^1.9.1",
"grpc_tools_node_protoc_ts": "^5.0.1"
"grpc_tools_node_protoc_ts": "^5.1.1",
"grpc-tools": "^1.10.0"
}
}