From b0f66d2d90e071e85353507cfacd93f6c38329c1 Mon Sep 17 00:00:00 2001 From: capt4ce Date: Fri, 9 Aug 2019 11:09:23 +0800 Subject: [PATCH 1/4] adds models and services required for download mechanism --- documentation.swagger.json | 1053 +------------------------------- model/accountBalance.proto | 6 +- model/block.proto | 37 +- model/blockchain.proto | 36 ++ model/host.proto | 6 + model/mempool.proto | 8 +- model/nodeRegistration.proto | 12 +- model/peer.proto | 4 +- model/transaction.proto | 22 +- service/host.proto | 2 +- service/p2pCommunication.proto | 6 + 11 files changed, 118 insertions(+), 1074 deletions(-) create mode 100644 model/blockchain.proto diff --git a/documentation.swagger.json b/documentation.swagger.json index b2c2215..2293efa 100644 --- a/documentation.swagger.json +++ b/documentation.swagger.json @@ -1,1039 +1,14 @@ -{ - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "schemes": [ - "http", - "https" - ], - "swagger": "2.0", - "info": { - "title": "service/account.proto", - "version": "version not set" - }, - "paths": { - "/v1/account/GetAccount": { - "get": { - "tags": [ - "AccountService" - ], - "operationId": "GetAccount", - "parameters": [ - { - "type": "integer", - "format": "int64", - "description": "Fetch Account by its ID.", - "name": "ID", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch Account by its account address (note: this in case of zoobc account type is the public key).", - "name": "Address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelAccount" - } - } - } - } - }, - "/v1/account/GetAccountBalance": { - "get": { - "tags": [ - "AccountBalanceService" - ], - "operationId": "GetAccountBalance", - "parameters": [ - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by type/address.", - "name": "AccountType", - "in": "query" - }, - { - "type": "string", - "name": "AccountAddress", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its Block height.", - "name": "BlockHeight", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelAccountBalance" - } - } - } - } - }, - "/v1/account/GetAccountBalances": { - "get": { - "tags": [ - "AccountBalanceService" - ], - "operationId": "GetAccountBalances", - "parameters": [ - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its balance (account balance \u003c BalanceLowerThan).", - "name": "BalanceLowerThan", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its balance (account balance \u003e BalanceHigherThan).", - "name": "BalanceHigherThan", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its spendablebalance (account spendablebalance \u003c BalanceLowerThan).", - "name": "SpendableBalanceLowerThan", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its spendablebalance (account spendablebalance \u003e BalanceHigherThan).", - "name": "SpendableBalanceHigherThan", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its spendablebalance (account spendablebalance \u003c BalanceLowerThan).", - "name": "PopRevenueBalanceLowerThan", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its popRevenuebalance (account popRevenuebalance \u003e BalanceHigherThan).", - "name": "PopRevenueBalanceHigherThan", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch AccountBalance by its Block height.", - "name": "BlockHeight", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelGetAccountBalancesResponse" - } - } - } - } - }, - "/v1/account/GetAccounts": { - "get": { - "tags": [ - "AccountService" - ], - "operationId": "GetAccounts", - "parameters": [ - { - "type": "integer", - "format": "int64", - "description": "Fetch Accounts by its account type.", - "name": "AccountType", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelGetAccountsResponse" - } - } - } - } - }, - "/v1/block/GetBlock": { - "get": { - "tags": [ - "BlockService" - ], - "operationId": "GetBlock", - "parameters": [ - { - "type": "integer", - "format": "int32", - "description": "Number indicating chaintype.", - "name": "ChainType", - "in": "query" - }, - { - "type": "string", - "format": "int64", - "description": "Block ID.", - "name": "ID", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "number of block to fetch.", - "name": "Height", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelBlock" - } - } - } - } - }, - "/v1/block/GetBlocks": { - "get": { - "tags": [ - "BlockService" - ], - "operationId": "GetBlocks", - "parameters": [ - { - "type": "integer", - "format": "int32", - "description": "Number indicating chaintype.", - "name": "ChainType", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Number of block to fetch.", - "name": "Limit", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "description": "Fetch block from `n` height.", - "name": "Height", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelGetBlocksResponse" - } - } - } - } - }, - "/v1/host/GetHostInfo": { - "get": { - "tags": [ - "HostService" - ], - "operationId": "GetHostInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelHost" - } - } - } - } - }, - "/v1/mempool/GetMempoolTransaction": { - "get": { - "tags": [ - "MempoolService" - ], - "operationId": "GetMempoolTransaction", - "parameters": [ - { - "type": "string", - "format": "byte", - "description": "Fetch Mempool Transaction by its TransactionBytes.", - "name": "TransactionBytes", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelMempoolTransaction" - } - } - } - } - }, - "/v1/mempool/GetMempoolTransactions": { - "get": { - "tags": [ - "MempoolService" - ], - "operationId": "GetMempoolTransactions", - "parameters": [ - { - "type": "string", - "format": "int64", - "description": "Fetch Mempool transactions from arrival timestamp.", - "name": "From", - "in": "query" - }, - { - "type": "string", - "format": "int64", - "description": "Fetch Mempool transactions to arrival timestamp.", - "name": "To", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelGetMempoolTransactionsResponse" - } - } - } - } - }, - "/v1/nodeRegistration/GetNodeRegistration": { - "get": { - "tags": [ - "NodeRegistrationService" - ], - "operationId": "GetNodeRegistration", - "parameters": [ - { - "type": "string", - "format": "byte", - "name": "NodePublicKey", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "name": "AccountType", - "in": "query" - }, - { - "type": "string", - "name": "AccountAddress", - "in": "query" - }, - { - "type": "string", - "format": "int64", - "name": "RegistrationHeight", - "in": "query" - }, - { - "type": "string", - "name": "NodeAddress", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelNodeRegistration" - } - } - } - } - }, - "/v1/nodeRegistration/GetNodeRegistrations": { - "get": { - "tags": [ - "NodeRegistrationService" - ], - "operationId": "GetNodeRegistrations", - "parameters": [ - { - "type": "string", - "format": "byte", - "name": "NodePublicKey", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "name": "AccountType", - "in": "query" - }, - { - "type": "string", - "name": "AccountAddress", - "in": "query" - }, - { - "type": "string", - "format": "int64", - "name": "RegistrationHeight", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelGetNodeRegistrationsResponse" - } - } - } - } - }, - "/v1/transaction/GetTransaction": { - "get": { - "tags": [ - "TransactionService" - ], - "operationId": "GetTransaction", - "parameters": [ - { - "type": "string", - "format": "int64", - "description": "Fetch Transaction by its ID.", - "name": "ID", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelTransaction" - } - } - } - } - }, - "/v1/transaction/GetTransactions": { - "get": { - "tags": [ - "TransactionService" - ], - "operationId": "GetTransactions", - "parameters": [ - { - "type": "integer", - "format": "int64", - "description": "Transactions set limit to be fetched.", - "name": "Limit", - "in": "query" - }, - { - "type": "string", - "format": "uint64", - "description": "Transactions set offset to be fetched.", - "name": "Offset", - "in": "query" - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelGetTransactionsResponse" - } - } - } - } - }, - "/v1/transaction/PostTransaction": { - "post": { - "tags": [ - "TransactionService" - ], - "operationId": "PostTransaction", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/modelPostTransactionResponse" - } - } - } - } - } - }, - "definitions": { - "modelAccount": { - "type": "object", - "title": "Account represent the transaction data structure stored in the database", - "properties": { - "AccountType": { - "type": "integer", - "format": "int64" - }, - "Address": { - "type": "string" - }, - "ID": { - "type": "string", - "format": "byte" - } - } - }, - "modelAccountBalance": { - "type": "object", - "title": "AccountBalance represent the transaction data structure stored in the database", - "properties": { - "AccountID": { - "type": "string", - "format": "byte" - }, - "Balance": { - "type": "string", - "format": "int64" - }, - "BlockHeight": { - "type": "integer", - "format": "int64" - }, - "Latest": { - "type": "boolean", - "format": "boolean" - }, - "PopRevenue": { - "type": "string", - "format": "int64" - }, - "SpendableBalance": { - "type": "string", - "format": "int64" - } - } - }, - "modelBlock": { - "type": "object", - "title": "Block represent the block data structure stored in the database", - "properties": { - "BlockSeed": { - "type": "string", - "format": "byte" - }, - "BlockSignature": { - "type": "string", - "format": "byte" - }, - "BlocksmithID": { - "type": "string", - "format": "byte" - }, - "CumulativeDifficulty": { - "type": "string" - }, - "Height": { - "type": "integer", - "format": "int64" - }, - "ID": { - "type": "string", - "format": "int64" - }, - "PayloadHash": { - "type": "string", - "format": "byte" - }, - "PayloadLength": { - "type": "integer", - "format": "int64" - }, - "PreviousBlockHash": { - "type": "string", - "format": "byte" - }, - "SmithScale": { - "type": "string", - "format": "int64" - }, - "Timestamp": { - "type": "string", - "format": "int64" - }, - "TotalAmount": { - "type": "string", - "format": "int64" - }, - "TotalCoinBase": { - "type": "string", - "format": "int64" - }, - "TotalFee": { - "type": "string", - "format": "int64" - }, - "Transactions": { - "type": "array", - "items": { - "$ref": "#/definitions/modelTransaction" - } - }, - "Version": { - "type": "integer", - "format": "int64" - } - } - }, - "modelEmpty": { - "type": "object", - "title": "Empty structure to represent empty parameter in proto" - }, - "modelEmptyTransactionBody": { - "type": "object" - }, - "modelGetAccountBalancesResponse": { - "type": "object", - "properties": { - "AccountBalance": { - "type": "array", - "title": "AccountBalances returned", - "items": { - "$ref": "#/definitions/modelAccountBalance" - } - }, - "AccountBalanceSize": { - "type": "integer", - "format": "int64", - "title": "Number of accounts returned" - } - } - }, - "modelGetAccountsResponse": { - "type": "object", - "properties": { - "Account": { - "type": "array", - "title": "Accounts returned", - "items": { - "$ref": "#/definitions/modelAccount" - } - }, - "AccountSize": { - "type": "integer", - "format": "int64", - "title": "Number of accounts returned" - } - } - }, - "modelGetBlocksResponse": { - "type": "object", - "properties": { - "ChainType": { - "type": "integer", - "format": "int32", - "title": "Number indicating chaintype" - }, - "Count": { - "type": "integer", - "format": "int64", - "title": "Number of block returned" - }, - "Height": { - "type": "integer", - "format": "int64", - "title": "Blocks height returned from" - }, - "blocks": { - "type": "array", - "title": "Blocks returned", - "items": { - "$ref": "#/definitions/modelBlock" - } - } - } - }, - "modelGetMempoolTransactionsResponse": { - "type": "object", - "properties": { - "MempoolSize": { - "type": "integer", - "format": "int64", - "title": "Number of transactions returned" - }, - "MempoolTransactions": { - "type": "array", - "title": "Mempool transactions returned", - "items": { - "$ref": "#/definitions/modelMempoolTransaction" - } - } - } - }, - "modelGetMorePeersResponse": { - "type": "object", - "properties": { - "Peers": { - "type": "array", - "items": { - "$ref": "#/definitions/modelNode" - } - } - } - }, - "modelGetNodeRegistrationsResponse": { - "type": "object", - "properties": { - "AccountAddress": { - "type": "string" - }, - "AccountType": { - "type": "integer", - "format": "int64" - }, - "LockedBalance": { - "type": "string", - "format": "int64" - }, - "NodeAddress": { - "type": "string" - }, - "NodePublicKey": { - "type": "string", - "format": "byte" - }, - "RegistrationHeight": { - "type": "string", - "format": "int64" - } - } - }, - "modelGetTransactionsResponse": { - "type": "object", - "properties": { - "Count": { - "type": "integer", - "format": "int64", - "title": "Number of transactions returned" - }, - "Total": { - "type": "string", - "format": "uint64", - "title": "Number of transactions in total" - }, - "Transactions": { - "type": "array", - "title": "Transaction transactions returned", - "items": { - "$ref": "#/definitions/modelTransaction" - } - } - } - }, - "modelHost": { - "type": "object", - "title": "Host represent", - "properties": { - "BlacklistedPeers": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/modelPeer" - } - }, - "Info": { - "$ref": "#/definitions/modelNode" - }, - "KnownPeers": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/modelPeer" - } - }, - "ResolvedPeers": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/modelPeer" - } - }, - "Stopped": { - "type": "boolean", - "format": "boolean" - }, - "UnresolvedPeers": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/modelPeer" - } - } - } - }, - "modelMempoolTransaction": { - "type": "object", - "title": "Mempool represent the mempool data structure stored in the database", - "properties": { - "ArrivalTimestamp": { - "type": "string", - "format": "int64" - }, - "FeePerByte": { - "type": "integer", - "format": "int32" - }, - "ID": { - "type": "string", - "format": "int64" - }, - "TransactionBytes": { - "type": "string", - "format": "byte" - } - } - }, - "modelNode": { - "type": "object", - "title": "NodeInfo represent the node information data structure", - "properties": { - "Address": { - "type": "string" - }, - "Port": { - "type": "integer", - "format": "int64" - }, - "SharedAddress": { - "type": "string" - } - } - }, - "modelNodeRegistration": { - "type": "object", - "properties": { - "AccountId": { - "type": "string", - "format": "byte" - }, - "Height": { - "type": "integer", - "format": "int64" - }, - "Latest": { - "type": "boolean", - "format": "boolean" - }, - "LockedBalance": { - "type": "string", - "format": "int64" - }, - "NodeAddress": { - "type": "string" - }, - "NodePublicKey": { - "type": "string", - "format": "byte" - }, - "Queued": { - "type": "boolean", - "format": "boolean" - }, - "RegistrationHeight": { - "type": "string", - "format": "int64" - } - } - }, - "modelNodeRegistrationTransactionBody": { - "type": "object", - "properties": { - "AccountAddress": { - "type": "string" - }, - "AccountType": { - "type": "integer", - "format": "int64" - }, - "LockedBalance": { - "type": "string", - "format": "int64" - }, - "NodeAddress": { - "type": "string" - }, - "NodePublicKey": { - "type": "string", - "format": "byte" - }, - "Poown": { - "$ref": "#/definitions/modelProofOfOwnership" - }, - "RegistrationHeight": { - "type": "string", - "format": "int64" - } - } - }, - "modelPeer": { - "type": "object", - "properties": { - "BlacklistingCause": { - "type": "string" - }, - "BlacklistingTime": { - "type": "string", - "format": "uint64" - }, - "Info": { - "$ref": "#/definitions/modelNode" - }, - "LastInboundRequest": { - "type": "integer", - "format": "int64" - }, - "LastUpdated": { - "type": "string", - "format": "int64" - }, - "connectionAttempted": { - "type": "integer", - "format": "int32" - } - } - }, - "modelPostTransactionResponse": { - "type": "object", - "properties": { - "Transaction": { - "$ref": "#/definitions/modelTransaction" - } - } - }, - "modelProofOfOwnership": { - "type": "object", - "title": "TODO: shall we move this to a different file?", - "properties": { - "AccountAddress": { - "type": "string" - }, - "AccountType": { - "type": "integer", - "format": "int64" - }, - "blockHash": { - "type": "string", - "format": "byte" - }, - "blockHeight": { - "type": "integer", - "format": "int64" - }, - "signature": { - "type": "string", - "format": "byte" - } - } - }, - "modelSendMoneyTransactionBody": { - "type": "object", - "properties": { - "Amount": { - "type": "string", - "format": "int64" - } - } - }, - "modelTransaction": { - "type": "object", - "title": "Transaction represent the transaction data structure stored in the database", - "properties": { - "BlockID": { - "type": "string", - "format": "int64" - }, - "Fee": { - "type": "string", - "format": "int64" - }, - "Height": { - "type": "integer", - "format": "int64" - }, - "ID": { - "type": "string", - "format": "int64" - }, - "RecipientAccountAddress": { - "type": "string" - }, - "RecipientAccountType": { - "type": "integer", - "format": "int64" - }, - "SenderAccountAddress": { - "type": "string" - }, - "SenderAccountType": { - "type": "integer", - "format": "int64" - }, - "Signature": { - "type": "string", - "format": "byte" - }, - "Timestamp": { - "type": "string", - "format": "int64" - }, - "TransactionBodyBytes": { - "type": "string", - "format": "byte" - }, - "TransactionBodyLength": { - "type": "integer", - "format": "int64" - }, - "TransactionHash": { - "type": "string", - "format": "byte" - }, - "TransactionType": { - "type": "integer", - "format": "int64" - }, - "Version": { - "type": "integer", - "format": "int64" - }, - "emptyTransactionBody": { - "$ref": "#/definitions/modelEmptyTransactionBody" - }, - "nodeRegistrationTransactionBody": { - "$ref": "#/definitions/modelNodeRegistrationTransactionBody" - }, - "sendMoneyTransactionBody": { - "$ref": "#/definitions/modelSendMoneyTransactionBody" - } - } - } - } -} + +error: invalid command: mixin +Usage: swagger [options] [command] + +Options: + -V, --version output the version number + -h, --help output usage information + +Commands: + project project actions + docs open Swagger documentation + validate [options] [swaggerFile] validate a Swagger document (supports unix piping) + convert [options] [apiDeclarations...] Converts Swagger 1.2 documents to a Swagger 2.0 document + help [cmd] display help for [cmd] diff --git a/model/accountBalance.proto b/model/accountBalance.proto index 50cc6dd..80b2cb6 100644 --- a/model/accountBalance.proto +++ b/model/accountBalance.proto @@ -8,9 +8,9 @@ option go_package = "github.com/zoobc/zoobc-core/common/model"; message AccountBalance { bytes AccountID = 1; uint32 BlockHeight = 2; - int64 SpendableBalance = 3; - int64 Balance = 4; - int64 PopRevenue = 5; + int64 SpendableBalance = 3 [jstype = JS_STRING]; + int64 Balance = 4 [jstype = JS_STRING]; + int64 PopRevenue = 5 [jstype = JS_STRING]; bool Latest = 6; } diff --git a/model/block.proto b/model/block.proto index 5cd46f4..a0720df 100644 --- a/model/block.proto +++ b/model/block.proto @@ -8,18 +8,18 @@ import "model/transaction.proto"; // Block represent the block data structure stored in the database message Block { - int64 ID = 1; + int64 ID = 1 [jstype = JS_STRING]; bytes PreviousBlockHash = 2; uint32 Height = 3; - int64 Timestamp = 4; + int64 Timestamp = 4 [jstype = JS_STRING]; bytes BlockSeed = 5; bytes BlockSignature = 6; string CumulativeDifficulty = 7; - int64 SmithScale = 8; + int64 SmithScale = 8 [jstype = JS_STRING]; bytes BlocksmithID = 9; - int64 TotalAmount = 10; - int64 TotalFee = 11; - int64 TotalCoinBase = 12; + int64 TotalAmount = 10 [jstype = JS_STRING]; + int64 TotalFee = 11 [jstype = JS_STRING]; + int64 TotalCoinBase = 12 [jstype = JS_STRING]; uint32 Version = 13; uint32 PayloadLength = 14; bytes PayloadHash = 15; @@ -31,7 +31,7 @@ message GetBlockRequest { // Number indicating chaintype int32 ChainType = 1; // Block ID - int64 ID = 2; + int64 ID = 2 [jstype = JS_STRING] ; // number of block to fetch uint32 Height = 3; } @@ -54,5 +54,26 @@ message GetBlocksResponse { // Blocks height returned from uint32 Height = 3; // Blocks returned - repeated Block blocks = 4; + repeated Block Blocks = 4; } + +message GetNextBlockIdsRequest { + // Number indicating chaintype + int32 ChainType = 1; + int64 BlockId =2 [jstype = JS_STRING]; + uint32 Limit = 3; +} +message BlockIdsResponse { + repeated int64 BlockIds = 1 [jstype = JS_STRING]; +} + +message GetNextBlocksRequest { + // Number indicating chaintype + int32 ChainType = 1; + int64 BlockId = 2 [jstype = JS_STRING]; + repeated int64 BlockIds = 3 [jstype = JS_STRING]; +} + +message BlocksData { + repeated Block Blocks = 1; +} \ No newline at end of file diff --git a/model/blockchain.proto b/model/blockchain.proto new file mode 100644 index 0000000..8a8114d --- /dev/null +++ b/model/blockchain.proto @@ -0,0 +1,36 @@ +syntax="proto3"; + +package model; + +option go_package = "github.com/zoobc/zoobc-core/common/model"; + +import "model/block.proto"; + +message ChainStatus{ + // Integer indicating chaintype + int32 ChainType = 1; + uint32 Height = 2; + Block LastBlock = 3; +} + +message GetCumulativeDifficultyResponse { + string CumulativeDifficulty = 1; + uint32 Height = 2; +} + +message GetCumulativeDifficultyRequest { + // Integer indicating chaintype + int32 ChainType = 1; +} + +message GetCommonMilestoneBlockIdsRequest { + // Integer indicating chaintype + int32 ChainType = 1; + int64 lastBlockId = 2 [jstype = JS_STRING]; + int64 lastMilestoneBlockId = 3 [jstype = JS_STRING]; +} + +message GetCommonMilestoneBlockIdsResponse { + repeated int64 blockIds = 1 [jstype = JS_STRING]; + bool last = 2; +} \ No newline at end of file diff --git a/model/host.proto b/model/host.proto index 87c910b..a9d8d39 100644 --- a/model/host.proto +++ b/model/host.proto @@ -6,6 +6,7 @@ option go_package = "github.com/zoobc/zoobc-core/common/model"; import "model/node.proto"; import "model/peer.proto"; +import "model/blockchain.proto"; // Host represent message Host { @@ -16,3 +17,8 @@ message Host { map BlacklistedPeers = 5; bool Stopped = 6; } + +message HostInfo{ + Host Host = 1; + repeated ChainStatus ChainStatus = 2; +} \ No newline at end of file diff --git a/model/mempool.proto b/model/mempool.proto index 1f46807..f40c65b 100644 --- a/model/mempool.proto +++ b/model/mempool.proto @@ -6,9 +6,9 @@ option go_package = "github.com/zoobc/zoobc-core/common/model"; // Mempool represent the mempool data structure stored in the database message MempoolTransaction { - int64 ID = 1; + int64 ID = 1 [jstype = JS_STRING]; int32 FeePerByte = 2; - int64 ArrivalTimestamp = 3; + int64 ArrivalTimestamp = 3 [jstype = JS_STRING]; bytes TransactionBytes = 4; } @@ -19,9 +19,9 @@ message GetMempoolTransactionRequest { message GetMempoolTransactionsRequest { // Fetch Mempool transactions from arrival timestamp - int64 From = 1; + int64 From = 1 [jstype = JS_STRING]; // Fetch Mempool transactions to arrival timestamp - int64 To = 2; + int64 To = 2 [jstype = JS_STRING]; } diff --git a/model/nodeRegistration.proto b/model/nodeRegistration.proto index 2a3e660..f47f5e8 100644 --- a/model/nodeRegistration.proto +++ b/model/nodeRegistration.proto @@ -8,9 +8,9 @@ option go_package = "github.com/zoobc/zoobc-core/common/model"; message NodeRegistration { bytes NodePublicKey = 1; bytes AccountId = 2; - int64 RegistrationHeight = 3; + int64 RegistrationHeight = 3 [jstype = JS_STRING]; string NodeAddress = 4; - int64 LockedBalance = 5; + int64 LockedBalance = 5 [jstype = JS_STRING]; bool Queued = 6; bool Latest = 7; uint32 Height = 8; @@ -21,7 +21,7 @@ message GetNodeRegistrationsRequest { bytes NodePublicKey = 1; uint32 AccountType = 2; string AccountAddress = 3; - int64 RegistrationHeight = 4; + int64 RegistrationHeight = 4 [jstype = JS_STRING]; } // GetNodeRegistrationRequest create request for single node register @@ -29,7 +29,7 @@ message GetNodeRegistrationRequest { bytes NodePublicKey = 1; uint32 AccountType = 2; string AccountAddress = 3; - int64 RegistrationHeight = 4; + int64 RegistrationHeight = 4 [jstype = JS_STRING]; string NodeAddress = 5; } @@ -37,7 +37,7 @@ message GetNodeRegistrationsResponse { bytes NodePublicKey = 1; uint32 AccountType = 2; string AccountAddress = 3; - int64 RegistrationHeight = 4; + int64 RegistrationHeight = 4 [jstype = JS_STRING]; string NodeAddress = 5; - int64 LockedBalance = 6; + int64 LockedBalance = 6 [jstype = JS_STRING]; } \ No newline at end of file diff --git a/model/peer.proto b/model/peer.proto index 3f54b29..c770a1d 100644 --- a/model/peer.proto +++ b/model/peer.proto @@ -10,8 +10,8 @@ message Peer { Node Info = 1; uint32 LastInboundRequest = 2; string BlacklistingCause = 3; - uint64 BlacklistingTime = 4; - int64 LastUpdated = 5; + uint64 BlacklistingTime = 4 [jstype = JS_STRING]; + int64 LastUpdated = 5 [jstype = JS_STRING]; int32 connectionAttempted = 6; } diff --git a/model/transaction.proto b/model/transaction.proto index f619b4d..bed32b4 100644 --- a/model/transaction.proto +++ b/model/transaction.proto @@ -7,16 +7,16 @@ option go_package = "github.com/zoobc/zoobc-core/common/model"; // Transaction represent the transaction data structure stored in the database message Transaction { uint32 Version = 1; - int64 ID = 2; - int64 BlockID = 3; + int64 ID = 2 [jstype = JS_STRING]; + int64 BlockID = 3 [jstype = JS_STRING]; uint32 Height = 4; uint32 SenderAccountType = 5; string SenderAccountAddress = 6; uint32 RecipientAccountType = 7; string RecipientAccountAddress = 8; uint32 TransactionType = 9; - int64 Fee = 10; - int64 Timestamp = 11; + int64 Fee = 10 [jstype = JS_STRING]; + int64 Timestamp = 11 [jstype = JS_STRING]; bytes TransactionHash = 12; uint32 TransactionBodyLength = 13; bytes TransactionBodyBytes = 14; @@ -32,16 +32,16 @@ message Transaction { message EmptyTransactionBody {} message SendMoneyTransactionBody { - int64 Amount = 1; + int64 Amount = 1 [jstype = JS_STRING]; } message NodeRegistrationTransactionBody { bytes NodePublicKey = 1; uint32 AccountType = 2; string AccountAddress = 3; - int64 RegistrationHeight = 4; + int64 RegistrationHeight = 4 [jstype = JS_STRING]; string NodeAddress = 5; - int64 LockedBalance = 6; + int64 LockedBalance = 6 [jstype = JS_STRING]; ProofOfOwnership Poown = 7; } @@ -56,14 +56,14 @@ message ProofOfOwnership { message GetTransactionRequest { // Fetch Transaction by its ID - int64 ID = 1; + int64 ID = 1 [jstype = JS_STRING]; } message GetTransactionsRequest { // Transactions set limit to be fetched uint32 Limit = 1; // Transactions set offset to be fetched - uint64 Offset = 2; + uint64 Offset = 2 [jstype = JS_STRING]; } message PostTransactionRequest { @@ -77,7 +77,7 @@ message PostTransactionResponse { message GetTransactionsResponse { // Number of transactions in total - uint64 Total = 1; + uint64 Total = 1 [jstype = JS_STRING]; // Number of transactions returned uint32 Count = 2; // Transaction transactions returned @@ -87,5 +87,5 @@ message GetTransactionsResponse { message PostUnconfirmedTransactionRequest { Transaction Transaction = 1; uint32 ArrivalTimestamp = 2; - int64 FeePerByte = 3; + int64 FeePerByte = 3 [jstype = JS_STRING]; } diff --git a/service/host.proto b/service/host.proto index 47a3772..33f1e25 100644 --- a/service/host.proto +++ b/service/host.proto @@ -10,7 +10,7 @@ import "google/api/annotations.proto"; // HostService represent request on Blockchain's Block service HostService { - rpc GetHostInfo(model.Empty) returns (model.Host) { + rpc GetHostInfo(model.Empty) returns (model.HostInfo) { option (google.api.http) = { get: "/v1/host/GetHostInfo" }; diff --git a/service/p2pCommunication.proto b/service/p2pCommunication.proto index 5c5e38c..f063c3e 100644 --- a/service/p2pCommunication.proto +++ b/service/p2pCommunication.proto @@ -7,9 +7,15 @@ option go_package = "github.com/zoobc/zoobc-core/common/service"; import "model/peer.proto"; import "model/node.proto"; import "model/empty.proto"; +import "model/block.proto"; +import "model/blockchain.proto"; service P2PCommunication { rpc GetPeerInfo(model.GetPeerInfoRequest) returns (model.Node) {} rpc GetMorePeers(model.Empty) returns (model.GetMorePeersResponse) {} rpc SendPeers(model.SendPeersRequest) returns (model.Empty) {} + rpc GetCumulativeDifficulty(model.GetCumulativeDifficultyRequest) returns (model.GetCumulativeDifficultyResponse){} + rpc GetCommonMilestoneBlockIDs(model.GetCommonMilestoneBlockIdsRequest) returns (model.GetCommonMilestoneBlockIdsResponse) {} + rpc GetNextBlockIDs(model.GetNextBlockIdsRequest) returns (model.BlockIdsResponse) {} + rpc GetNextBlocks(model.GetNextBlocksRequest) returns (model.BlocksData) {} } From 8de4d3b964d605eee8c929260276ea429223e8a1 Mon Sep 17 00:00:00 2001 From: capt4ce Date: Mon, 12 Aug 2019 17:39:54 +0800 Subject: [PATCH 2/4] solves conflicts --- google/api/annotations.proto | 31 ++++ google/api/http.proto | 291 +++++++++++++++++++++++++++++++++ model/accountBalance.proto | 6 +- model/block.proto | 2 +- model/host.proto | 2 +- model/mempool.proto | 2 + model/nodeRegistration.proto | 45 +++-- model/transaction.proto | 37 ++++- service/accountBalance.proto | 2 +- service/nodeRegistration.proto | 6 + service/p2pCommunication.proto | 4 + 11 files changed, 400 insertions(+), 28 deletions(-) create mode 100644 google/api/annotations.proto create mode 100644 google/api/http.proto diff --git a/google/api/annotations.proto b/google/api/annotations.proto new file mode 100644 index 0000000..85c361b --- /dev/null +++ b/google/api/annotations.proto @@ -0,0 +1,31 @@ +// Copyright (c) 2015, Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/api/http.proto"; +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "AnnotationsProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // See `HttpRule`. + HttpRule http = 72295728; +} diff --git a/google/api/http.proto b/google/api/http.proto new file mode 100644 index 0000000..5f8538a --- /dev/null +++ b/google/api/http.proto @@ -0,0 +1,291 @@ +// Copyright 2016 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "HttpProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + + +// Defines the HTTP configuration for a service. It contains a list of +// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method +// to one or more HTTP REST API methods. +message Http { + // A list of HTTP configuration rules that apply to individual API methods. + // + // **NOTE:** All service configuration rules follow "last one wins" order. + repeated HttpRule rules = 1; +} + +// `HttpRule` defines the mapping of an RPC method to one or more HTTP +// REST APIs. The mapping determines what portions of the request +// message are populated from the path, query parameters, or body of +// the HTTP request. The mapping is typically specified as an +// `google.api.http` annotation, see "google/api/annotations.proto" +// for details. +// +// The mapping consists of a field specifying the path template and +// method kind. The path template can refer to fields in the request +// message, as in the example below which describes a REST GET +// operation on a resource collection of messages: +// +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; +// } +// } +// message GetMessageRequest { +// message SubMessage { +// string subfield = 1; +// } +// string message_id = 1; // mapped to the URL +// SubMessage sub = 2; // `sub.subfield` is url-mapped +// } +// message Message { +// string text = 1; // content of the resource +// } +// +// The same http annotation can alternatively be expressed inside the +// `GRPC API Configuration` YAML file. +// +// http: +// rules: +// - selector: .Messaging.GetMessage +// get: /v1/messages/{message_id}/{sub.subfield} +// +// This definition enables an automatic, bidrectional mapping of HTTP +// JSON to RPC. Example: +// +// HTTP | RPC +// -----|----- +// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` +// +// In general, not only fields but also field paths can be referenced +// from a path pattern. Fields mapped to the path pattern cannot be +// repeated and must have a primitive (non-message) type. +// +// Any fields in the request message which are not bound by the path +// pattern automatically become (optional) HTTP query +// parameters. Assume the following definition of the request message: +// +// +// message GetMessageRequest { +// message SubMessage { +// string subfield = 1; +// } +// string message_id = 1; // mapped to the URL +// int64 revision = 2; // becomes a parameter +// SubMessage sub = 3; // `sub.subfield` becomes a parameter +// } +// +// +// This enables a HTTP JSON to RPC mapping as below: +// +// HTTP | RPC +// -----|----- +// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` +// +// Note that fields which are mapped to HTTP parameters must have a +// primitive type or a repeated primitive type. Message types are not +// allowed. In the case of a repeated type, the parameter can be +// repeated in the URL, as in `...?param=A¶m=B`. +// +// For HTTP method kinds which allow a request body, the `body` field +// specifies the mapping. Consider a REST update method on the +// message resource collection: +// +// +// service Messaging { +// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { +// option (google.api.http) = { +// put: "/v1/messages/{message_id}" +// body: "message" +// }; +// } +// } +// message UpdateMessageRequest { +// string message_id = 1; // mapped to the URL +// Message message = 2; // mapped to the body +// } +// +// +// The following HTTP JSON to RPC mapping is enabled, where the +// representation of the JSON in the request body is determined by +// protos JSON encoding: +// +// HTTP | RPC +// -----|----- +// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` +// +// The special name `*` can be used in the body mapping to define that +// every field not bound by the path template should be mapped to the +// request body. This enables the following alternative definition of +// the update method: +// +// service Messaging { +// rpc UpdateMessage(Message) returns (Message) { +// option (google.api.http) = { +// put: "/v1/messages/{message_id}" +// body: "*" +// }; +// } +// } +// message Message { +// string message_id = 1; +// string text = 2; +// } +// +// +// The following HTTP JSON to RPC mapping is enabled: +// +// HTTP | RPC +// -----|----- +// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` +// +// Note that when using `*` in the body mapping, it is not possible to +// have HTTP parameters, as all fields not bound by the path end in +// the body. This makes this option more rarely used in practice of +// defining REST APIs. The common usage of `*` is in custom methods +// which don't use the URL at all for transferring data. +// +// It is possible to define multiple HTTP methods for one RPC by using +// the `additional_bindings` option. Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/messages/{message_id}" +// additional_bindings { +// get: "/v1/users/{user_id}/messages/{message_id}" +// } +// }; +// } +// } +// message GetMessageRequest { +// string message_id = 1; +// string user_id = 2; +// } +// +// +// This enables the following two alternative HTTP JSON to RPC +// mappings: +// +// HTTP | RPC +// -----|----- +// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` +// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` +// +// # Rules for HTTP mapping +// +// The rules for mapping HTTP path, query parameters, and body fields +// to the request message are as follows: +// +// 1. The `body` field specifies either `*` or a field path, or is +// omitted. If omitted, it assumes there is no HTTP body. +// 2. Leaf fields (recursive expansion of nested messages in the +// request) can be classified into three types: +// (a) Matched in the URL template. +// (b) Covered by body (if body is `*`, everything except (a) fields; +// else everything under the body field) +// (c) All other fields. +// 3. URL query parameters found in the HTTP request are mapped to (c) fields. +// 4. Any body sent with an HTTP request can contain only (b) fields. +// +// The syntax of the path template is as follows: +// +// Template = "/" Segments [ Verb ] ; +// Segments = Segment { "/" Segment } ; +// Segment = "*" | "**" | LITERAL | Variable ; +// Variable = "{" FieldPath [ "=" Segments ] "}" ; +// FieldPath = IDENT { "." IDENT } ; +// Verb = ":" LITERAL ; +// +// The syntax `*` matches a single path segment. It follows the semantics of +// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String +// Expansion. +// +// The syntax `**` matches zero or more path segments. It follows the semantics +// of [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.3 Reserved +// Expansion. NOTE: it must be the last segment in the path except the Verb. +// +// The syntax `LITERAL` matches literal text in the URL path. +// +// The syntax `Variable` matches the entire path as specified by its template; +// this nested template must not contain further variables. If a variable +// matches a single path segment, its template may be omitted, e.g. `{var}` +// is equivalent to `{var=*}`. +// +// NOTE: the field paths in variables and in the `body` must not refer to +// repeated fields or map fields. +// +// Use CustomHttpPattern to specify any HTTP method that is not included in the +// `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for +// a given URL path rule. The wild-card rule is useful for services that provide +// content to Web (HTML) clients. +message HttpRule { + // Selects methods to which this rule applies. + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + string selector = 1; + + // Determines the URL pattern is matched by this rules. This pattern can be + // used with any of the {get|put|post|delete|patch} methods. A custom method + // can be defined using the 'custom' field. + oneof pattern { + // Used for listing and getting information about resources. + string get = 2; + + // Used for updating a resource. + string put = 3; + + // Used for creating a resource. + string post = 4; + + // Used for deleting a resource. + string delete = 5; + + // Used for updating a resource. + string patch = 6; + + // Custom pattern is used for defining custom verbs. + CustomHttpPattern custom = 8; + } + + // The name of the request field whose value is mapped to the HTTP body, or + // `*` for mapping all fields not captured by the path pattern to the HTTP + // body. NOTE: the referred field must not be a repeated field and must be + // present at the top-level of request message type. + string body = 7; + + // Additional HTTP bindings for the selector. Nested bindings must + // not contain an `additional_bindings` field themselves (that is, + // the nesting may only be one level deep). + repeated HttpRule additional_bindings = 11; +} + +// A custom pattern is used for defining custom HTTP verb. +message CustomHttpPattern { + // The name of this custom HTTP verb. + string kind = 1; + + // The path matched by this custom verb. + string path = 2; +} diff --git a/model/accountBalance.proto b/model/accountBalance.proto index 80b2cb6..86256f8 100644 --- a/model/accountBalance.proto +++ b/model/accountBalance.proto @@ -18,8 +18,10 @@ message GetAccountBalanceRequest { // Fetch AccountBalance by type/address uint32 AccountType = 1; string AccountAddress = 2; - // Fetch AccountBalance by its Block height - uint32 BlockHeight = 3; +} + +message GetAccountBalanceResponse { + AccountBalance AccountBalance = 1; } message GetAccountBalancesRequest { diff --git a/model/block.proto b/model/block.proto index a0720df..c71bb04 100644 --- a/model/block.proto +++ b/model/block.proto @@ -75,5 +75,5 @@ message GetNextBlocksRequest { } message BlocksData { - repeated Block Blocks = 1; + repeated Block NextBlocks = 1; } \ No newline at end of file diff --git a/model/host.proto b/model/host.proto index a9d8d39..0406dbd 100644 --- a/model/host.proto +++ b/model/host.proto @@ -8,7 +8,7 @@ import "model/node.proto"; import "model/peer.proto"; import "model/blockchain.proto"; -// Host represent +// Host represent data sructure node and listed peers in node it's self message Host { Node Info = 1; map ResolvedPeers = 2; diff --git a/model/mempool.proto b/model/mempool.proto index f40c65b..6d77401 100644 --- a/model/mempool.proto +++ b/model/mempool.proto @@ -10,6 +10,8 @@ message MempoolTransaction { int32 FeePerByte = 2; int64 ArrivalTimestamp = 3 [jstype = JS_STRING]; bytes TransactionBytes = 4; + bytes SenderAccountID = 5; + bytes RecipientAccountID = 6; } message GetMempoolTransactionRequest { diff --git a/model/nodeRegistration.proto b/model/nodeRegistration.proto index f47f5e8..273c43d 100644 --- a/model/nodeRegistration.proto +++ b/model/nodeRegistration.proto @@ -6,14 +6,15 @@ option go_package = "github.com/zoobc/zoobc-core/common/model"; message NodeRegistration { - bytes NodePublicKey = 1; - bytes AccountId = 2; - int64 RegistrationHeight = 3 [jstype = JS_STRING]; - string NodeAddress = 4; - int64 LockedBalance = 5 [jstype = JS_STRING]; - bool Queued = 6; - bool Latest = 7; - uint32 Height = 8; + int64 NodeID = 1 [jstype = JS_STRING]; + bytes NodePublicKey = 2; + bytes AccountId = 3; + uint32 RegistrationHeight = 4; + string NodeAddress = 5; + int64 LockedBalance = 6 [jstype = JS_STRING]; + bool Queued = 7; + bool Latest = 8; + uint32 Height = 9; } // GetNodeRegisterRequest create request to get a list node @@ -21,7 +22,7 @@ message GetNodeRegistrationsRequest { bytes NodePublicKey = 1; uint32 AccountType = 2; string AccountAddress = 3; - int64 RegistrationHeight = 4 [jstype = JS_STRING]; + uint32 RegistrationHeight = 4; } // GetNodeRegistrationRequest create request for single node register @@ -29,15 +30,29 @@ message GetNodeRegistrationRequest { bytes NodePublicKey = 1; uint32 AccountType = 2; string AccountAddress = 3; - int64 RegistrationHeight = 4 [jstype = JS_STRING]; + uint32 RegistrationHeight = 4; string NodeAddress = 5; } -message GetNodeRegistrationsResponse { - bytes NodePublicKey = 1; - uint32 AccountType = 2; - string AccountAddress = 3; - int64 RegistrationHeight = 4 [jstype = JS_STRING]; +// UpdateNodeRegistrationRequest create request for single node update +message UpdateNodeRegistrationRequest { + bytes ID = 1; + bytes NodePublicKey = 2; + uint32 AccountType = 3; + string AccountAddress = 4; string NodeAddress = 5; int64 LockedBalance = 6 [jstype = JS_STRING]; +} + +message GetNodeRegistrationsResponse { + bytes ID = 1; + bytes NodePublicKey = 2; + uint32 AccountType = 3; + string AccountAddress = 4; + uint32 RegistrationHeight = 5; + string NodeAddress = 6; + int64 LockedBalance = 7 [jstype = JS_STRING]; + bool Queued = 8; + bool Latest = 9; + uint32 Height = 10; } \ No newline at end of file diff --git a/model/transaction.proto b/model/transaction.proto index bed32b4..10bbfdd 100644 --- a/model/transaction.proto +++ b/model/transaction.proto @@ -25,8 +25,9 @@ message Transaction { EmptyTransactionBody emptyTransactionBody = 15; SendMoneyTransactionBody sendMoneyTransactionBody = 16; NodeRegistrationTransactionBody nodeRegistrationTransactionBody = 17; + UpdateNodeRegistrationTransactionBody updateNodeRegistrationTransactionBody = 18; } - bytes Signature = 18; + bytes Signature = 19; } message EmptyTransactionBody {} @@ -39,19 +40,33 @@ message NodeRegistrationTransactionBody { bytes NodePublicKey = 1; uint32 AccountType = 2; string AccountAddress = 3; - int64 RegistrationHeight = 4 [jstype = JS_STRING]; - string NodeAddress = 5; - int64 LockedBalance = 6 [jstype = JS_STRING]; - ProofOfOwnership Poown = 7; + uint32 RegistrationHeight = 4; + uint32 NodeAddressLength = 5; + string NodeAddress = 6; + int64 LockedBalance = 7 [jstype = JS_STRING]; + ProofOfOwnership Poown = 8; +} + +message UpdateNodeRegistrationTransactionBody { + bytes NodePublicKey = 1; + uint32 NodeAddressLength = 2; + string NodeAddress = 3; + int64 LockedBalance = 4 [jstype = JS_STRING]; + ProofOfOwnership Poown = 5; } //TODO: shall we move this to a different file? message ProofOfOwnership { + bytes MessageBytes = 1; + bytes Signature = 2; +} + +//TODO: shall we move this to a different file? +message ProofOfOwnershipMessage { uint32 AccountType = 1; string AccountAddress = 2; - bytes blockHash = 3; - uint32 blockHeight = 4; - bytes signature = 5; + bytes BlockHash = 3; + uint32 BlockHeight = 4; } message GetTransactionRequest { @@ -84,6 +99,12 @@ message GetTransactionsResponse { repeated Transaction Transactions = 3; } +// SendTransaction request in p2pCommunication service +message SendTransactionRequest { + bytes TransactionBytes = 1; +} + +// TODO: Currently not yet used. Should we delete it? message PostUnconfirmedTransactionRequest { Transaction Transaction = 1; uint32 ArrivalTimestamp = 2; diff --git a/service/accountBalance.proto b/service/accountBalance.proto index d7271c9..6782ce8 100644 --- a/service/accountBalance.proto +++ b/service/accountBalance.proto @@ -15,7 +15,7 @@ service AccountBalanceService { }; } - rpc GetAccountBalance(model.GetAccountBalanceRequest) returns (model.AccountBalance) { + rpc GetAccountBalance(model.GetAccountBalanceRequest) returns (model.GetAccountBalanceResponse) { option (google.api.http) = { get: "/v1/account/GetAccountBalance" }; diff --git a/service/nodeRegistration.proto b/service/nodeRegistration.proto index 2ac6ec5..cfce6cb 100644 --- a/service/nodeRegistration.proto +++ b/service/nodeRegistration.proto @@ -20,4 +20,10 @@ service NodeRegistrationService { get: "/v1/nodeRegistration/GetNodeRegistration" }; } + + rpc UpdateNodeRegistration(model.UpdateNodeRegistrationRequest) returns (model.NodeRegistration) { + option (google.api.http) = { + get: "/v1/nodeRegistration/UpdateNodeRegistration" + }; + } } diff --git a/service/p2pCommunication.proto b/service/p2pCommunication.proto index f063c3e..b7536b3 100644 --- a/service/p2pCommunication.proto +++ b/service/p2pCommunication.proto @@ -9,11 +9,15 @@ import "model/node.proto"; import "model/empty.proto"; import "model/block.proto"; import "model/blockchain.proto"; +import "model/transaction.proto"; service P2PCommunication { rpc GetPeerInfo(model.GetPeerInfoRequest) returns (model.Node) {} rpc GetMorePeers(model.Empty) returns (model.GetMorePeersResponse) {} rpc SendPeers(model.SendPeersRequest) returns (model.Empty) {} + rpc SendBlock (model.Block) returns (model.Empty) {} + rpc SendTransaction (model.SendTransactionRequest) returns (model.Empty) {} + rpc GetCumulativeDifficulty(model.GetCumulativeDifficultyRequest) returns (model.GetCumulativeDifficultyResponse){} rpc GetCommonMilestoneBlockIDs(model.GetCommonMilestoneBlockIdsRequest) returns (model.GetCommonMilestoneBlockIdsResponse) {} rpc GetNextBlockIDs(model.GetNextBlockIdsRequest) returns (model.BlockIdsResponse) {} From d7c70b34025df5bf76e74cd474c6452fe433fd78 Mon Sep 17 00:00:00 2001 From: capt4ce Date: Thu, 15 Aug 2019 15:28:45 +0800 Subject: [PATCH 3/4] changes the cases of attributes --- model/blockchain.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model/blockchain.proto b/model/blockchain.proto index 8a8114d..c6b0a89 100644 --- a/model/blockchain.proto +++ b/model/blockchain.proto @@ -26,11 +26,11 @@ message GetCumulativeDifficultyRequest { message GetCommonMilestoneBlockIdsRequest { // Integer indicating chaintype int32 ChainType = 1; - int64 lastBlockId = 2 [jstype = JS_STRING]; - int64 lastMilestoneBlockId = 3 [jstype = JS_STRING]; + int64 LastBlockID = 2 [jstype = JS_STRING]; + int64 LastMilestoneBlockID = 3 [jstype = JS_STRING]; } message GetCommonMilestoneBlockIdsResponse { - repeated int64 blockIds = 1 [jstype = JS_STRING]; - bool last = 2; + repeated int64 BlockIds = 1 [jstype = JS_STRING]; + bool Last = 2; } \ No newline at end of file From 99c3f929eb787fd65700bade092d5d71f7758e8a Mon Sep 17 00:00:00 2001 From: capt4ce Date: Fri, 16 Aug 2019 15:20:23 +0800 Subject: [PATCH 4/4] changes ChainStatus to CHainStatuses --- model/host.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/host.proto b/model/host.proto index 0406dbd..9192d65 100644 --- a/model/host.proto +++ b/model/host.proto @@ -20,5 +20,5 @@ message Host { message HostInfo{ Host Host = 1; - repeated ChainStatus ChainStatus = 2; + repeated ChainStatus ChainStatuses = 2; } \ No newline at end of file