From adda4d96bcb27c09aff5a32af16c809b547960b3 Mon Sep 17 00:00:00 2001 From: Darcy Date: Mon, 9 Apr 2018 21:46:30 +0800 Subject: [PATCH 01/40] protocol revised --- Chinese version of TRON Protocol document.md | 519 ++++++++++++++++++ English version of TRON Protocol document.md | 544 +++++++++++++++++++ 2 files changed, 1063 insertions(+) create mode 100644 Chinese version of TRON Protocol document.md create mode 100644 English version of TRON Protocol document.md diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md new file mode 100644 index 00000000000..50089a8f5db --- /dev/null +++ b/Chinese version of TRON Protocol document.md @@ -0,0 +1,519 @@ +# TRON protobuf protocol + +## TRON使用Google protobuf协议,协议内容涉及到账户,区块,传输多个层面。 + ++ 账户有基本账户、资产发布账户和合约账户三种类型。一个账户包含:账户名称,账户类型,地址,余额,投票,其他资产6种属性。 ++ 更进一步的,基本账户可以申请成为验证节点,验证节点具有额外的属性,投票统计数目,公钥,URL,以及历史表现等参数。 + + 3种`Account`类型:`Normal`,`AssetIssue`,`Contract`。 + + enum AccountType {
 + Normal = 0;
 + AssetIssue = 1;
 + Contract = 2;
 + } + + 一个`Account`包含7种参数: + `account_name`:该账户的名称——比如: ”_SicCongsAccount_”。 + `type`:该账户的类型——比如: _0_ 代表的账户类型是`Normal`。 + `balance`:该账户的TRX余额——比如:_4213312_。 + `votes`:账户所得投票数——比如:_{(“0x1b7w…9xj3”,323),(“0x8djq…j12m”,88),…,(“0x82nd…mx6i”,10001)}_。 + `asset`:除TRX以外账户上的其他资产——比如:_{<”WishToken”,66666>,<”Dogie”,233>}_。 + `latest_operation_time`: 该账户的最新活跃时间。 + + // Account
 + message Account {
 + message Vote {
 + bytes vote_address = 1;
 + int64 vote_count = 2;
 + }
 + bytes accout_name = 1;
 + AccountType type = 2;
 + bytes address = 3;
 + int64 balance = 4;
 + repeated Vote votes = 5;
 + map asset = 6;
 + int64 latest_operation_time = 10; + } + + 一个`Witness`包含8种参数: + `address`:验证节点的地址——比如:_“0xu82h…7237”_。 + `voteCount`:验证节点所得投票数——比如:_234234_。 + `pubKey`:验证节点的公钥——比如:_“0xu82h…7237”_。 + `url`:验证节点的url链接——比如:_“https://www.noonetrust.com”_。 + `totalProduce`:验证节点产生的区块数——比如:_2434_。 + `totalMissed`:验证节点丢失的区块数——比如:_7_。 + `latestBlockNum`:最新的区块高度——比如:_4522_。 + `isJobs`:布尔表类型标志位。 + + // Witness
 + message Witness {
 + bytes address = 1;
 + int64 voteCount = 2;
 + bytes pubKey = 3;
 + string url = 4;
 + int64 totalProduced = 5;
 + int64 totalMissed = 6;
 + int64 latestBlockNum = 7; + bool isJobs = 9; + 
} + ++ 一个区块由区块头和多笔交易构成。区块头包含时间戳,交易字典树的根,父哈希,签名等区块基本信息。 + + 一个`block`包含`transactions`和`block_header`。 + `transactions`:区块里的交易信息。 + `block_header`:区块的组成部分之一。 + + // block
 + message Block {
 + repeated Transaction transactions = 1;
 + BlockHeader block_header = 2; + 
} + + `BlockHeader` 包括`raw_data`和`witness_signature`。 + `raw_data`:`raw`信息。 + `witness_signature`:区块头到验证节点的签名。 + + message `raw`包含6种参数: + `timestamp`:该消息体的时间戳——比如:_14356325_。 + `txTrieRoot`:Merkle Tree的根——比如:_“7dacsa…3ed”_。 + `parentHash`:上一个区块的哈希值——比如:_“7dacsa…3ed”_。 + `number`:区块高度——比如:_13534657_。 + `witness_id`:验证节点的id——比如:_“0xu82h…7237”_。 + `witness_address`:验证节点的地址——比如:_“0xu82h…7237”_。 + + message BlockHeader {
 + message raw {
 + int64 timestamp = 1;
 + bytes txTrieRoot = 2;
 + bytes parentHash = 3;
 + //bytes nonce = 5;
 + //bytes difficulty = 6;
 + uint64 number = 7;
 + uint64 witness_id = 8;
 + bytes witness_address = 9;
 + }
 + raw raw_data = 1;
 + bytes witness_signature = 2; + 
} + + 消息体 `ChainInventory` 包括 `BlockId` 和 `remain_num`。 + `BlockId`: block的身份信息。 + `remain_num`:在同步过程中,剩余的区块数量。 + + A `BlockId` contains 2 parameters: + `hash`: 该区块的哈希值。 + `number`: 哈希值和高度即为当前区块块号。 + + message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; + } + + ++ 交易合约有多种类型,包括账户创建合约、账户更新合约、转账合约、转账断言合约、资产投票合约、见证节点投票合约、见证节点创建合约、见证节点更新合约、资产发布合约、参与资产发布和与部署合约11种类型。 + + `AccountCreatContract`包含3种参数: + `type`:账户类型——比如:_0_ 代表的账户类型是`Normal`。 + `account_name`: 账户名称——比如: _"SiCongsaccount”_。 + `owner_address`:合约持有人地址——比如: _“0xu82h…7237”_。 + + message AccountCreateContract {
 + AccountType type = 1;
 + bytes account_name = 2;
 + bytes owner_address = 3;
 + } + `AccountUpdateContract`包含2种参数: + `account_name`: 账户名称——比如: _"SiCongsaccount”_。 + `owner_address`:合约持有人地址——比如: _“0xu82h…7237”_。 + + message AccountUpdateContract { + bytes account_name = 1; + bytes owner_address = 2; + } + + `TransferContract`包含3种参数: + `amount`:TRX数量——比如:_12534_。 + `to_address`: 接收方地址——比如:_“0xu82h…7237”_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + + message TransferContract {
 + bytes owner_address = 1;
 + bytes to_address = 2;
 + int64 amount = 3; + 
} + + `TransferAssetContract`包含4种参数: + `asset_name`:资产名称——比如:_”SiCongsaccount”_。 + `to_address`:接收方地址——比如:_“0xu82h…7237”_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `amount`:目标资产数量——比如:_12353_。 + + message TransferAssetContract {
 + bytes asset_name = 1;
 + bytes owner_address = 2;
 + bytes to_address = 3;
 + int64 amount = 4;
 + } + + `VoteAssetContract`包含4种参数: + `vote_address`:投票人地址——比如:_“0xu82h…7237”_。 + `support`:投票赞成与否——比如:_true_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `count`:投票数目——比如:_2324234_。 + + message VoteAssetContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5; + } + + `VoteWitnessContract`包含4种参数: + `vote_address`:投票人地址——比如:_“0xu82h…7237”_。 + `support`:投票赞成与否——比如:_true_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `count`:投票数目——比如:_32632_。 + + message VoteWitnessContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5;
 + } + + `WitnessCreateContract`包含3种参数: + `private_key`:合约的私钥——比如:_“0xu82h…7237”_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `url`:合约的url链接——比如:_“https://www.noonetrust.cn”_。 + + message WitnessCreateContract {
 + bytes owner_address = 1;
 + bytes private_key = 2;
 + bytes url = 12; + 
} + + `WitnessUpdateContract`包含2种参数: + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `update_url`:合约的url链接——比如:_“https://www.noonetrust.cn”_。 + + message WitnessUpdateContract { + bytes owner_address = 1; + bytes update_url = 12; + } + + `AssetIssueContract`包含11种参数: + `name`:合约名称——比如:_“SiCongcontract”_。 + `total_supply`:合约的赞成总票数——比如:_100000000_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `trx_num`:对应TRX数量——比如:_232241_。 + `num`: 对应的自定义资产数目。 + `start_time`:开始时间——比如:_20170312_。 + `end_time`:结束时间——比如:_20170512_。 + `decav_ratio`:衰减速率。 + `vote_score`:合约的评分——比如:_12343_。 + `description`:合约的描述——比如:_”trondada”_。 + `url`:合约的url地址链接——比如:_“https://www.noonetrust.cn”_。 + + message AssetIssueContract {
 + bytes owner_address = 1;
 + bytes name = 2;
 + int64 total_supply = 4;
 + int32 trx_num = 6;
 + int32 num = 8;
 + int64 start_time = 9;
 + int64 end_time = 10;
 + int32 decay_ratio = 15;
 + int32 vote_score = 16;
 + bytes description = 20;
 + bytes url = 21;
 + } + + `ParticipateAssetIssueContract`包含4种参数: + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `to_address`:接收方地址——比如:_“0xu82h…7237”_。 + `asset_name`: 目标资产的名称。 + `amount`: 小部分数量。 + + `DeployContract`包含2种参数: + `script`:脚本。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + + message DeployContract {
 + bytes owner_address = 1;
 + bytes script = 2;
 + } + + 消息体 `Result` 包含 `fee` and `ret`2个参数. + `ret`: 交易结果。 + `fee`: 交易扣除的费用。 + + `code`是`ret`的类型定义,有`SUCCESS`和`FAILED`两种类型。 + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + ++ 每一个交易还包含多个输入与多个输出,以及其他一些相关属性。其中交易内的输入,交易本身,区块头均需签名。 + + 消息体 `Transaction`包括`raw_data`和`signature`。 + `raw_data`: 消息体`raw`。 + `signature`: 所有输入节点的签名。 + + `raw_data`包含8种参数: + `type`:消息体raw的交易类型。 + `vin`: 输入值。 + `vout`: 输出值。 + `expiration`:过期时间——比如:_20170312_。 + `data`: 数据。 + `contract`: 该交易内的合约。 + `script`: 脚本。 + `timestamp`:该消息体的时间戳。 + + 消息体 `Contract`包含`type`和`parameter`。 + `type`:合约的类型。 + `parameter`:任意参数。 + + 有八种账户类型合约:`AccountCreateContract`,`TransferContract`,`TransferAssetContract`,`VoteAssetContract`,`VoteWitnessContract`,`WitnessCreateContract`,`AssetIssueContract` 和`DeployContract`。 + + `TransactionType`包括`UtxoType`和`ContractType`。 + + message Transaction {
 + enum TranscationType {
 + UtxoType = 0;
 + ContractType = 1;
 + }
 + message Contract {
 + enum ContractType {
 + AccountCreateContract = 0;
 + TransferContract = 1;
 + TransferAssetContract = 2;
 + VoteAssetContract = 3;
 + VoteWitnessContract = 4;
 + WitnessCreateContract = 5;
 + AssetIssueContract = 6;
 + DeployContract = 7;
 + }
 + ContractType type = 1;
 + google.protobuf.Any parameter = 2;
 + }
 + message raw {
 + TranscationType type = 2;
 + repeated TXInput vin = 5;
 + repeated TXOutput vout = 7;
 + int64 expiration = 8;
 + bytes data = 10;
 + repeated Contract contract = 11;
 + bytes scripts = 16;
 + in64 timestamp = 17; + }
 + raw raw_data = 1;
 + repeated bytes signature = 5;
 + } + + 消息体 `TXOutputs`由`outputs`构成。 + `outputs`: 元素为`TXOutput`的数组。 + + message TXOutputs {
 + repeated TXOutput outputs = 1; + 
} + + 消息体 `TXOutput`包括`value`和`pubKeyHash`。 + `value`:输出值。 + `pubKeyhash`:公钥的哈希。 + + message TXOutput {
 + int64 value = 1;
 + bytes pubKeyHash = 2; + 
} + + 消息体 `TXIutput`包括`raw_data`和`signature`。 + `raw_data`:消息体`raw`。 + `signature`:`TXInput`的签名。 + + 消息体 `raw`包含`txID`,`vout`和 `pubKey`。 + `txID`:交易ID。 + `Vout`:上一个输出的值。 + `pubkey`:公钥。 + + message TXInput {
 + message raw {
 + bytes txID = 1;
 + int64 vout = 2;
 + bytes pubKey = 3;
 + }
 + raw raw_data = 1;
 + bytes signature = 4;
} + ++ 传输涉及的协议Inventory主要用于传输中告知接收方传输数据的清单。 + + `Inventory`包括`type`和`ids`。 + `type`:清单类型——比如:_0_ 代表`TRX`。 + `ids`:清单中的物品ID。 + + `InventoryType`包含`TRX`和 `BLOCK`。 + `TRX`:交易。 + `BLOCK`:区块。 + + // Inventory
 + message Inventory {
 + enum InventoryType {
 + TRX = 0;
 + BLOCK = 1;
 + }
 + InventoryType type = 1;
 + repeated bytes ids = 2; + 
} + + 消息体 `Items`包含4种参数: + `type`:物品类型——比如:_1_ 代表 `TRX`。 + `blocks`:物品中区块。 + `blockheaders`:区块头。 + `transactions`:交易。 + + `Items`有四种类型,分别是 `ERR`, `TRX`,`BLOCK` 和`BLOCKHEADER`。 + `ERR`:错误。 + `TRX`:交易。 + `BLOCK`:区块。 + `BLOCKHEADER`:区块头。 + + message Items {
 + enum ItemType {
 + ERR = 0;
 + TRX = 1;
 + BLOCK = 2;
 + BLOCKHEADER = 3;
 + }
 + ItemType type = 1;
 + repeated Block blocks = 2;
 + repeated BlockHeader block_headers = 3;
 + repeated Transaction transactions = 4;
 + } + + `Inventory`包含`type`和`items`。 + `type`:物品种类。 + `items`:物品清单。 + + message InventoryItems {
 + int32 type = 1;
 + repeated bytes items = 2;
 + } + + 消息体 `BlockInventory` 包含 `type`。 + `type`: 清单种类. + + 有三种类型:`SYNC`, `ADVTISE`, `FETCH`。 + + // Inventory + message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + 消息体 `BlockId` 包括 `ids` and `type`。 + `ids`: 区块身份信息。 + `type`: 区块类型。 + + `ids` 包含2种参数: + `hash`: 区块的哈希值。 + `number`: 哈希值和区块高度即为当前区块号。 + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; + } + + `ReasonCode` 有15种可能断开的原因: + `REQUESTED` + `TCP_ERROR` + `BAD_PROTOCOL` + `USELESS_PEER` + `TOO_MANY_PEERS` + `DUPLICATE_PEER` + `INCOMPATIBLE_PROTOCOL` + `NULL_IDENTITY` + `PEER_QUITING` + `UNEXPECTED_IDENTITY` + `LOCAL_IDENTITY` + `PING_TIMEOU` + `USER_REASON` + `RESET` + `UNKNOWN` + + enum ReasonCode { + REQUESTED = 0; + TCP_ERROR = 1; + BAD_PROTOCOL = 2; + USELESS_PEER = 3; + TOO_MANY_PEERS = 4; + DUPLICATE_PEER = 5; + INCOMPATIBLE_PROTOCOL = 6; + NULL_IDENTITY = 7; + PEER_QUITING = 8; + UNEXPECTED_IDENTITY = 9; + LOCAL_IDENTITY = 10; + PING_TIMEOUT = 11; + USER_REASON = 12; + RESET = 16; + UNKNOWN = 255; + } + + 消息体`DisconnectMessage`包含`reason`。 + `DisconnectMessage`:断开连接是的消息。 + `reason`:断开连接时的原因。 + + 消息体`HelloMessage`包含2个参数: + `from`请:求建立连接的节点。 + `version`:建立连接的节点。 + ++ 钱包服务RPC + + `Wallet`钱包服务包含多个RPC。 + __`Getbalance`__:获取`Account`的余额。 + __`CreatTransaction`__:通过`TransferContract`创建交易。 + __`BroadcastTransaction`__:广播`Transaction`。 + __`CreateAccount`__:通过`AccountCreateContract`创建账户。 + __`CreatAssetContract`__:通过`AssetIssueContract`发布一个资产。 + + service Wallet {

 + + rpc GetBalance (Account) returns (Account) {

 + + };
 + rpc CreateTransaction (TransferContract) returns (Transaction) {

 + + };

 + rpc BroadcastTransaction (Transaction) returns (Return) {

 + + };

 + rpc CreateAccount(AccountCreateContract) returns (Transaction) {

 + + };

 rpc CreateAssetIssue(AssetIssueContract) returns (Transaction) {

 + + };

 + + }; + + 消息体`Return`只含有一个参数: + `result`: 布尔表类型标志位。 + + message `Return` {
 + bool result = 1;
 + } + + +# 详细的协议见附属文件。详细协议随着程序的迭代随时都可能发生变化,请以最新的版本为准。 \ No newline at end of file diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md new file mode 100644 index 00000000000..a2548e0367c --- /dev/null +++ b/English version of TRON Protocol document.md @@ -0,0 +1,544 @@ + +# Protobuf protocol + +## The protocol of TRON is defined by Google Protobuf and contains a range of layers, from account, block to transfer. + ++ There are 3 types of account—basic account, asset release account and contract account, and attributes included in each account are name, types, address, balance and related asset. ++ A basic account is able to apply to be a validation node, which has serval parameters, including extra attributes, public key, URL, voting statistics, history performance, etc. + + There are three different `Account types`: `Normal`, `AssetIssue`, `Contract`. + + enum AccountType {
 + Normal = 0;
 + AssetIssue = 1;
 + Contract = 2; + 
} + + An `Account` contains 7 parameters: + `account_name`: the name for this account – e.g. “_BillsAccount_”. + `type`: what type of this account is – e.g. _0_ stands for type `Normal`. + `balance`: balance of this account – e.g. _4213312_. + `votes`: received votes on this account – e.g. _{(“0x1b7w…9xj3”,323), (“0x8djq…j12m”,88),…,(“0x82nd…mx6i”,10001)}_. + `asset`: other assets expect TRX in this account – e.g. _{<“WishToken”,66666>,<”Dogie”,233>}_. + `latest_operation_time`: the latest operation time of this account. + + // Account
 + message Account {
 + message Vote {
 + bytes vote_address = 1;
 + int64 vote_count = 2;
 }
 + bytes accout_name = 1;
 + AccountType type = 2;
 + bytes address = 3;
 + int64 balance = 4;
 + repeated Vote votes = 5;
 + map asset = 6; + int64 latest_operation_time = 10;
 + } + + A `Witness` contains 8 parameters: + `address`: the address of this witness – e.g. “_0xu82h…7237_”. + `voteCount`: number of received votes on this witness – e.g. _234234_. + `pubKey`: the public key for this witness – e.g. “_0xu82h…7237_”. + `url`: the url for this witness – e.g. “_https://www.noonetrust.com_”. + `totalProduced`: the number of blocks this witness produced – e.g. _2434_. + `totalMissed`: the number of blocks this witness missed – e.g. _7_. + `latestBlockNum`: the latest height of block – e.g. _4522_. + `isjobs`: a bool flag. + + // Witness
 + message Witness{
 + bytes address = 1;
 + int64 voteCount = 2;
 + bytes pubKey = 3;
 + string url = 4;
 + int64 totalProduced = 5;
 + int64 totalMissed = 6;
 + int64 latestBlockNum = 7;
 + bool isJobs = 9; + } + ++ A block typically contains transaction data and a blockheader, which is a list of basic block information, including timestamp, signature, parent hash, root of Merkle tree and so on. + + A block contains `transactions` and a `block_header`. + `transactions`: transaction data of this block. + `block_header`: one part of a block. + + // block + 
message Block {
 + repeated Transaction transactions = 1;
 + BlockHeader block_header = 2;
 + } + + A `BlockHeader` contains `raw_data` and `witness_signature`. + `raw_data`: a `raw` message. + `witness_signature`: signature for this block header from witness node. + + A message `raw` contains 6 parameters: + `timestamp`: timestamp of this message – e.g. _14356325_. + `txTrieRoot`: the root of Merkle Tree in this block – e.g. “_7dacsa…3ed_.” + `parentHash`: the hash of last block – e.g. “_7dacsa…3ed_.” + `number`: the height of this block – e.g. _13534657_. + `witness_id`: the id of witness which packed this block – e.g. “_0xu82h…7237_”. + `witness_address`: the adresss of the witness packed this block – e.g. “_0xu82h…7237_”. + + message BlockHeader {
 + message raw {
 + int64 timestamp = 1;
 + bytes txTrieRoot = 2;
 + bytes parentHash = 3;
 + //bytes nonce = 5;
 + //bytes difficulty = 6;
 + uint64 number = 7;
 + uint64 witness_id = 8;
 + bytes witness_address = 9;
 + }
 + raw raw_data = 1;
 + bytes witness_signature = 2;
 + } + + message `ChainInventory` contains `BlockId` and `remain_num`. + `BlockId`: the identification of block. + `remain_num`:the remain number of blocks in the synchronizing process. + + A `BlockId` contains 2 parameters: + `hash`: the hash of block. + `number`: the hash and height of block. + + message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; + } + ++ Transaction contracts mainly includes account create contract, account update contract transfer contract, transfer asset contract, vote asset contract, vote witness contract, witness creation contract, witness update contract, asset issue contract, participate asset issue contract and deploy contract. + + An `AccountCreateContract` contains 3 parameters: + `type`: What type this account is – e.g. _0_ stands for `Normal`. + `account_name`: the name for this account – e.g.”_Billsaccount_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + + message AccountCreateContract {
 + AccountType type = 1;
 + bytes account_name = 2;
 + bytes owner_address = 3;
 + } + + A `AccountUpdateContract` contains 2 paremeters: + `account_name`: the name for this account – e.g.”_Billsaccount_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + + message AccountUpdateContract { + bytes account_name = 1; + bytes owner_address = 2; + } + + A `TransferContract` contains 3 parameters: + `amount`: the amount of TRX – e.g. _12534_. + `to_address`: the receiver address – e.g. “_0xu82h…7237_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + + message TransferContract {
 + bytes owner_address = 1;
 + bytes to_address = 2;
 + int64 amount = 3; + } + + A `TransferAssetContract` contains 4 parameters: + `asset_name`: the name for asset – e.g.”_Billsaccount_”. + `to_address`: the receiver address – e.g. “_0xu82h…7237_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `amount`: the amount of target asset - e.g._12353_. + + message TransferAssetContract {
 + bytes asset_name = 1;
 + bytes owner_address = 2;
 + bytes to_address = 3;
 + int64 amount = 4;
 + } + + A `VoteAssetContract` contains 4 parameters: + `vote_address`: the voted address of the asset. + `support`: is the votes supportive or not – e.g. _true_. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `count`: the count number of votes- e.g. _2324234_. + + message VoteAssetContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5;
 + } + + A `VoteWitnessContract` contains 4 parameters: + `vote_address`: the addresses of those who voted. + `support`: is the votes supportive or not - e.g. _true_. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `count`: - e.g. the count number of vote – e.g. _32632_. + + message VoteWitnessContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5; + 
} + + A `WitnessCreateContract` contains 3 parameters: + `private_key`: the private key of contract– e.g. “_0xu82h…7237_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `url`: the url for the witness – e.g. “_https://www.noonetrust.com_”. + + message WitnessCreateContract {
 + bytes owner_address = 1;
 + bytes private_key = 2;
 + bytes url = 12;
 + } + + A `WitnessUpdateContract` contains 2 parameters: + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `update_url`: the url for the witness – e.g. “_https://www.noonetrust.com_”. + + message WitnessUpdateContract { + bytes owner_address = 1; + bytes update_url = 12; + } + + An `AssetIssueContract` contains 11 parameters: + `owner_address`: the address for contract owner – e.g. “_0xu82h…7237_”. + `name`: the name for this contract – e.g. “Billscontract”. + `total_supply`: the maximum supply of this asset – e.g. _1000000000_. + `trx_num`: the number of TRONIX – e.g._232241_. + `num`: number of corresponding asset. + `start_time`: the starting date of this contract – e.g._20170312_. + `end_time`: the expiring date of this contract – e.g. _20170512_. + `decay_ratio`: decay ratio. + `vote_score`: the vote score of this contract received – e.g. _12343_. + `description`: the description of this contract – e.g.”_trondada_”. + `url`: the url of this contract – e.g. “_https://www.noonetrust.com_”. + + message AssetIssueContract {
 + bytes owner_address = 1;
 + bytes name = 2;
 + int64 total_supply = 4;
 + int32 trx_num = 6;
 + int32 num = 8;
 + int64 start_time = 9;
 + int64 end_time = 10;
 + int32 decay_ratio = 15;
 + int32 vote_score = 16;
 + bytes description = 20;
 + bytes url = 21;
 + } + + A `ParticipateAssetIssueContract` contains 4 parameters: + `owner_address`: the address for contract owner – e.g. “_0xu82h…7237_”. + `to_address`: the receiver address – e.g. “_0xu82h…7237_”. + `asset_name`: the name of target asset. + `amount`: the amount of drops. + + message ParticipateAssetIssueContract { + bytes owner_address = 1; + bytes to_address = 2; + bytes asset_name = 3; + int64 amount = 4; + } + + A `DeployContract` contains 2 parameters: + `script`: the script of this contract. + `owner_address`: the address for contract owner – e.g. “_0xu82h…7237_”. + + message DeployContract {
 + bytes owner_address = 1;
 + bytes script = 2; + 
} t + ++ Each transaction contains several TXInputs, TXOutputs and other related qualities. +Input, transaction and head block all require signature. + + message `Transaction` contains `raw_data` and `signature`. + `raw_data`: message `raw`. + `signature`: signatures form all input nodes. + + `raw` contains 8 parameters: + `type`: the transaction type of `raw` message. + `vin`: input values. + `vout`: output values. + `expiration`: the expiration date of transaction – e.g._20170312_. + `data`: data. + `contract`: contracts in this transaction. + `scripts`:scripts in the transaction. + `timestamp`: timestamp of this raw data – e.g. _14356325_. + + message `Contract` contains `type` and `parameter`. + `type`: what type of the message contract. + `parameter`: It can be any form. + + There are 8 different of contract types: `AccountCreateContract`, `TransferContract`, `TransferAssetContract`, `VoteAssetContract`, `VoteWitnessContract`,`WitnessCreateContract`, `AssetIssueContract` and `DeployContract`. + `TransactionType` have two types: `UtxoType` and `ContractType`. + + message Transaction {
 + enum TranscationType {
 + UtxoType = 0;
 + ContractType = 1;
 + }
 + message Contract {
 + enum ContractType {
 + AccountCreateContract = 0;
 + TransferContract = 1;
 + TransferAssetContract = 2;
 + VoteAssetContract = 3;
 + VoteWitnessContract = 4;
 + WitnessCreateContract = 5;
 + AssetIssueContract = 6;
 + DeployContract = 7;
 + WitnessUpdateContract = 8; + ParticipateAssetIssueContract = 9 + }
 + ContractType type = 1;
 + google.protobuf.Any parameter = 2;
 + }
 + message raw {
 + TranscationType type = 2;
 + repeated TXInput vin = 5;
 + repeated TXOutput vout = 7;
 + int64 expiration = 8;
 + bytes data = 10;
 + repeated Contract contract = 11;
 + bytes scripts = 16;
 + int64 timestamp = 17; + }
 + raw raw_data = 1;
 + repeated bytes signature = 5; + 
} + + message `TXOutputs` contains `outputs`. + `outputs`: an array of `TXOutput`. + + message TXOutputs {
 + repeated TXOutput outputs = 1;
 + } + + message `TXOutput` contains `value` and `pubKeyHash`. + `value`: output value. + `pubKeyHash`: Hash of public key + + message TXOutput {
 + int64 value = 1;
 + bytes pubKeyHash = 2;
 + } + + message `TXInput` contains `raw_data` and `signature`. + `raw_data`: a message `raw`. + `signature`: signature for this `TXInput`. + + message `raw` contains `txID`, `vout` and `pubKey`. + `txID`: transaction ID. + `vout`: value of last output. + `pubKey`: public key. + + message TXInput {
 + message raw {
 + bytes txID = 1;
 + int64 vout = 2;
 + bytes pubKey = 3;
 + }
 + raw raw_data = 1;
 + bytes signature = 4; + 
} + + message `Result` contains `fee` and `ret`. + `ret`: the state of transaction. + `fee`: the fee for transaction. + + `code` is definition of `ret` and contains 2 types:`SUCCESS` and `FAILED`. + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + ++ Inventory is mainly used to inform peer nodes the list of items. + + `Inventory` contains `type` and `ids`. + `type`: what type this `Inventory` is. – e.g. _0_ stands for `TRX`. + `ids`: ID of things in this `Inventory`. + + Two `Inventory` types: `TRX` and `BLOCK`. + `TRX`: transaction. + `BLOCK`: block. + + // Inventory
 + message Inventory {
 + enum InventoryType {
 + TRX = 0;
 + BLOCK = 1;
 + }
 + InventoryType type = 1;
 + repeated bytes ids = 2;
 + } + + message `Items` contains 4 parameters: + `type`: type of items – e.g. _1_ stands for `TRX`. + `blocks`: blocks in `Items` if there is any. + `block_headers`: block headers if there is any. + `transactions`: transactions if there is any. + + `Items` have four types: `ERR`, `TRX`, `BLOCK` and `BLOCKHEADER`. + `ERR`: error. + `TRX`: transaction. + `BLOCK`: block. + `BLOCKHEADER`: block header. + + message Items {
 + enum ItemType {
 + ERR = 0;
 + TRX = 1;
 + BLOCK = 2;
 + BLOCKHEADER = 3;
 + }
 + ItemType type = 1;
 + repeated Block blocks = 2;
 + repeated BlockHeader + block_headers = 3;
 + repeated Transaction transactions = 4; + } + + `InventoryItems` contains `type` and `items`. + `type`: what type of item. + `items`: items in an `InventoryItems`. + + message InventoryItems {
 + int32 type = 1;
 + repeated bytes items = 2; + 
} + + message `BlockInventory` contains `type`. + `type`: what type of inventory. + + There are 3 types:`SYNC`, `ADVTISE`, `FETCH`. + + // Inventory + message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message `BlockId` contains `ids` and `type`. + `ids`: the identification of block. + `type`: what type of the block. + + `ids` contains 2 paremeters: + `hash`: the hash of block. + `number`: the hash and height of block. + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; + } + + `ReasonCode`: the type of reason. + + `ReasonCode` contains 15 types of disconnect reasons: + `REQUESTED` + `TCP_ERROR` + `BAD_PROTOCOL` + `USELESS_PEER` + `TOO_MANY_PEERS` + `DUPLICATE_PEER` + `INCOMPATIBLE_PROTOCOL` + `NULL_IDENTITY` + `PEER_QUITING` + `UNEXPECTED_IDENTITY` + `LOCAL_IDENTITY` + `PING_TIMEOUT` + `USER_REASON` + `RESET` + `UNKNOWN` + + enum ReasonCode { + REQUESTED = 0; + TCP_ERROR = 1; + BAD_PROTOCOL = 2; + USELESS_PEER = 3; + TOO_MANY_PEERS = 4; + DUPLICATE_PEER = 5; + INCOMPATIBLE_PROTOCOL = 6; + NULL_IDENTITY = 7; + PEER_QUITING = 8; + UNEXPECTED_IDENTITY = 9; + LOCAL_IDENTITY = 10; + PING_TIMEOUT = 11; + USER_REASON = 12; + RESET = 16; + UNKNOWN = 255; + } + + message`DisconnectMessage` contains `reason`. + `DisconnectMessage`: the message when disconnection occurs. + `reason`: the reason for disconnecting. + + message`HelloMessage` contains 2 parameters: + `HelloMessage`: the message for building connection. + `from`: the nodes that request for building connection. + `version`: the version when connection is built. + + + ++ Wallet Service RPC + + `Wallet` service contains several RPCs. + __`GetBalance`__ : + Return balance of an `Account`. + __`CreateTransaction`__ : + Create a transaction by giving a `TransferContract`. A Transaction containing a transaction creation will be returned. + __`BroadcastTransaction`__ : + Broadcast a `Transaction`. A `Return` will be returned indicating if broadcast is success of not. + __`CreateAccount`__ : + Create an account by giving a `AccountCreateContract`. + __`CreatAssetContract`__ : + Issue an asset by giving a `AssetIssueContract`. + + service Wallet {

 + + rpc GetBalance (Account) returns (Account) {

 + + };
 + rpc CreateTransaction (TransferContract) returns + (Transaction) {

 + + };

 + + rpc BroadcastTransaction (Transaction) returns (Return) {

 + + };

 + + rpc CreateAccount(AccountCreateContract) returns + (Transaction) {

 + + };

 + + rpc CreateAssetIssue(AssetIssueContract) returns + (Transaction) {

 + + };

 + + }; + + message `Return` has only one parameter: + `result`: a bool flag. + message `Return` {
 bool result = 1;
} + + +# Please check detailed protocol document that may change with the iteration of the program at any time. Please refer to the latest version. From b1ad4591660c6b35dd120e44602f6c03c8138e11 Mon Sep 17 00:00:00 2001 From: Darcy Date: Mon, 9 Apr 2018 21:59:08 +0800 Subject: [PATCH 02/40] revised --- Chinese version of TRON Protocol document.md | 5 +- English version of TRON Protocol document.md | 48 ++++++++++---------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index 50089a8f5db..cfbc0e8d26e 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -113,8 +113,7 @@ repeated BlockId ids = 1; int64 remain_num = 2; } - - + + 交易合约有多种类型,包括账户创建合约、账户更新合约、转账合约、转账断言合约、资产投票合约、见证节点投票合约、见证节点创建合约、见证节点更新合约、资产发布合约、参与资产发布和与部署合约11种类型。 `AccountCreatContract`包含3种参数: @@ -261,7 +260,6 @@ } int64 fee = 1; code ret = 2; - } + 每一个交易还包含多个输入与多个输出,以及其他一些相关属性。其中交易内的输入,交易本身,区块头均需签名。 @@ -515,5 +513,4 @@ bool result = 1;
 } - # 详细的协议见附属文件。详细协议随着程序的迭代随时都可能发生变化,请以最新的版本为准。 \ No newline at end of file diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index a2548e0367c..53cbcd51492 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -448,24 +448,24 @@ Input, transaction and head block all require signature. Type type = 2; } - `ReasonCode`: the type of reason. + `ReasonCode`: the type of reason. - `ReasonCode` contains 15 types of disconnect reasons: - `REQUESTED` - `TCP_ERROR` - `BAD_PROTOCOL` - `USELESS_PEER` - `TOO_MANY_PEERS` - `DUPLICATE_PEER` - `INCOMPATIBLE_PROTOCOL` - `NULL_IDENTITY` - `PEER_QUITING` - `UNEXPECTED_IDENTITY` - `LOCAL_IDENTITY` - `PING_TIMEOUT` - `USER_REASON` - `RESET` - `UNKNOWN` + `ReasonCode` contains 15 types of disconnect reasons: + `REQUESTED` + `TCP_ERROR` + `BAD_PROTOCOL` + `USELESS_PEER` + `TOO_MANY_PEERS` + `DUPLICATE_PEER` + `INCOMPATIBLE_PROTOCOL` + `NULL_IDENTITY` + `PEER_QUITING` + `UNEXPECTED_IDENTITY` + `LOCAL_IDENTITY` + `PING_TIMEOUT` + `USER_REASON` + `RESET` + `UNKNOWN` enum ReasonCode { REQUESTED = 0; @@ -485,14 +485,14 @@ Input, transaction and head block all require signature. UNKNOWN = 255; } - message`DisconnectMessage` contains `reason`. - `DisconnectMessage`: the message when disconnection occurs. - `reason`: the reason for disconnecting. + message`DisconnectMessage` contains `reason`. + `DisconnectMessage`: the message when disconnection occurs. + `reason`: the reason for disconnecting. - message`HelloMessage` contains 2 parameters: - `HelloMessage`: the message for building connection. - `from`: the nodes that request for building connection. - `version`: the version when connection is built. + message`HelloMessage` contains 2 parameters: + `HelloMessage`: the message for building connection. + `from`: the nodes that request for building connection. + `version`: the version when connection is built. From 2b3e1578ccbc911329a95d13828c46619b6dbd19 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 12:43:50 +0800 Subject: [PATCH 03/40] revised --- Chinese version of TRON Protocol document.md | 88 ++++++++++++++++++++ English version of TRON Protocol document.md | 69 ++++++++++++++- 2 files changed, 155 insertions(+), 2 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index cfbc0e8d26e..1b70a78c8ac 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -506,11 +506,99 @@ }; + 消息体`Return`只含有一个参数: `result`: 布尔表类型标志位。 message `Return` {
 bool result = 1;
 } ++ 网络UDP消息结构。 + + `Endpoint`:网络中节点信息存储结构. + 消息体`Endpoint` 包含3个参数: + `address`: 节点地址。 + `port`:端口号。 + `nodeId`: 节点ID信息。 + + message Endpoint { + bytes address = 1; + int32 port = 2; + bytes nodeId = 3; + } + + `PingMessage`:节点建立连接时所发送的消息。 + 消息体`PingMessage` 包含4个参数: + `from`:消息来自的节点。 + `to`: 消息发送的节点。 + `version`: 网络版本。 + `timestamp`:消息创建时的时间戳。 + + message PingMessage { + Endpoint from = 1; + Endpoint to = 2; + int32 version = 3; + int64 timestamp = 4; + } + + `PongMessage`:连接建立成功时的回复消息。 + 消息体`PongMessage` 包含3个参数: + `from`:消息来自的节点。 + `echo`: + `timestamp`:消息创建时的时间戳。 + + message PongMessage { + Endpoint from = 1; + int32 echo = 2; + int64 timestamp = 3; + } + + `FindNeighbours`:节点查询相邻节点时所发送的消息。 + 消息体`FindNeighbours` 包含3个参数: + `from`: 消息来自的节点。 + `targetId`: 目标节点的信息。 + `timestamp`: 消息创建时的时间戳。 + + message FindNeighbours { + Endpoint from = 1; + bytes targetId = 2; + int64 timestamp = 3; + } + + `Neighbour`:相邻接点回复消息。 + 消息体`Neighbours` 包含3个参数: + `from`: 消息来自的节点。 + `neighbours`: 相邻节点。 + `timestamp`: 消息体创建时的时间戳。 + + message Neighbours { + Endpoint from = 1; + repeated Endpoint neighbours = 2; + int64 timestamp = 3; + } + + + + + + + + + + + + + + + + + + + + + + + + # 详细的协议见附属文件。详细协议随着程序的迭代随时都可能发生变化,请以最新的版本为准。 \ No newline at end of file diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index 53cbcd51492..2472a359d47 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -536,9 +536,74 @@ Input, transaction and head block all require signature. }; - message `Return` has only one parameter: + + message `Return` has only one parameter: `result`: a bool flag. - message `Return` {
 bool result = 1;
} + message `Return` {
 bool result = 1;
} + ++ The message structure of UDP. + `Endpoint`: the storage structure of nodes' information. + message`Endpoint` contains 3 parameters: + `address`: the address of nodes. + `port`: the port number. + `nodeId`:the ID of nodes. + + + message Endpoint { + bytes address = 1; + int32 port = 2; + bytes nodeId = 3; + } + + `PingMessage`: the message sent from one node to another in the connecting process. + message`PingMessage` contains 4 parameters: + `from`: whcih node does the message send from. + `to`: which node will the message send to. + `version`: the version of the Internet. + `timestamp`: the timestamp of message. + + message PingMessage { + Endpoint from = 1; + Endpoint to = 2; + int32 version = 3; + int64 timestamp = 4; + } + + `PongMessage`: the message implies that nodes are connected. + message`PongMessage` contains 3 parameters: + `from`: whcih node does the message send from. + `echo`: + `timestamp`: the timestamp of message. + + message PongMessage { + Endpoint from = 1; + int32 echo = 2; + int64 timestamp = 3; + } + + `FindNeighbours`: the message sent from one node to find another one. + message`FindNeighbours` contains 3 parameters: + `from`: whcih node does the message send from. + `targetId`: the ID of targeted node. + `timestamp`: the timestamp of message. + + message FindNeighbours { + Endpoint from = 1; + bytes targetId = 2; + int64 timestamp = 3; + } + + `FindNeighbour`: the message replied by the neighbour node. + message`Neighbours` contains 3 parameters: + `from`: whcih node does the message send from. + `neighbours`: the neighbour node. + `timestamp`: the timestamp of message. + + message Neighbours { + Endpoint from = 1; + repeated Endpoint neighbours = 2; + int64 timestamp = 3; + } # Please check detailed protocol document that may change with the iteration of the program at any time. Please refer to the latest version. From 9e9a5b42d3eda707dbb765f20c1b0204c4d6d702 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 14:58:01 +0800 Subject: [PATCH 04/40] revised --- English version of TRON Protocol document.md | 256 +++++++++---------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index 2472a359d47..164ef7c0502 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -279,56 +279,56 @@ Input, transaction and head block all require signature. There are 8 different of contract types: `AccountCreateContract`, `TransferContract`, `TransferAssetContract`, `VoteAssetContract`, `VoteWitnessContract`,`WitnessCreateContract`, `AssetIssueContract` and `DeployContract`. `TransactionType` have two types: `UtxoType` and `ContractType`. - message Transaction {
 - enum TranscationType {
 - UtxoType = 0;
 - ContractType = 1;
 - }
 - message Contract {
 - enum ContractType {
 - AccountCreateContract = 0;
 - TransferContract = 1;
 - TransferAssetContract = 2;
 - VoteAssetContract = 3;
 - VoteWitnessContract = 4;
 - WitnessCreateContract = 5;
 - AssetIssueContract = 6;
 - DeployContract = 7;
 - WitnessUpdateContract = 8; - ParticipateAssetIssueContract = 9 - }
 - ContractType type = 1;
 - google.protobuf.Any parameter = 2;
 - }
 - message raw {
 - TranscationType type = 2;
 - repeated TXInput vin = 5;
 - repeated TXOutput vout = 7;
 - int64 expiration = 8;
 - bytes data = 10;
 - repeated Contract contract = 11;
 - bytes scripts = 16;
 - int64 timestamp = 17; + message Transaction {
 + enum TranscationType {
 + UtxoType = 0;
 + ContractType = 1;
 }
 - raw raw_data = 1;
 - repeated bytes signature = 5; - 
} + message Contract {
 + enum ContractType {
 + AccountCreateContract = 0;
 + TransferContract = 1;
 + TransferAssetContract = 2;
 + VoteAssetContract = 3;
 + VoteWitnessContract = 4;
 + WitnessCreateContract = 5;
 + AssetIssueContract = 6;
 + DeployContract = 7;
 + WitnessUpdateContract = 8; + ParticipateAssetIssueContract = 9 + }
 + ContractType type = 1;
 + google.protobuf.Any parameter = 2;
 + }
 + message raw {
 + TranscationType type = 2;
 + repeated TXInput vin = 5;
 + repeated TXOutput vout = 7;
 + int64 expiration = 8;
 + bytes data = 10;
 + repeated Contract contract = 11;
 + bytes scripts = 16;
 + int64 timestamp = 17; + }
 + raw raw_data = 1;
 + repeated bytes signature = 5; + 
} message `TXOutputs` contains `outputs`. `outputs`: an array of `TXOutput`. - message TXOutputs {
 - repeated TXOutput outputs = 1;
 - } + message TXOutputs {
 + repeated TXOutput outputs = 1;
 + } message `TXOutput` contains `value` and `pubKeyHash`. `value`: output value. `pubKeyHash`: Hash of public key - message TXOutput {
 - int64 value = 1;
 - bytes pubKeyHash = 2;
 - } + message TXOutput {
 + int64 value = 1;
 + bytes pubKeyHash = 2;
 + } message `TXInput` contains `raw_data` and `signature`. `raw_data`: a message `raw`. @@ -339,15 +339,15 @@ Input, transaction and head block all require signature. `vout`: value of last output. `pubKey`: public key. - message TXInput {
 - message raw {
 - bytes txID = 1;
 - int64 vout = 2;
 - bytes pubKey = 3;
 + message TXInput {
 + message raw {
 + bytes txID = 1;
 + int64 vout = 2;
 + bytes pubKey = 3;
 }
 raw raw_data = 1;
 bytes signature = 4; - 
} + 
} message `Result` contains `fee` and `ret`. `ret`: the state of transaction. @@ -374,15 +374,15 @@ Input, transaction and head block all require signature. `TRX`: transaction. `BLOCK`: block. - // Inventory
 - message Inventory {
 - enum InventoryType {
 - TRX = 0;
 - BLOCK = 1;
 - }
 - InventoryType type = 1;
 - repeated bytes ids = 2;
 - } + // Inventory
 + message Inventory {
 + enum InventoryType {
 + TRX = 0;
 + BLOCK = 1;
 + }
 + InventoryType type = 1;
 + repeated bytes ids = 2;
 + } message `Items` contains 4 parameters: `type`: type of items – e.g. _1_ stands for `TRX`. @@ -396,41 +396,41 @@ Input, transaction and head block all require signature. `BLOCK`: block. `BLOCKHEADER`: block header. - message Items {
 - enum ItemType {
 - ERR = 0;
 - TRX = 1;
 - BLOCK = 2;
 - BLOCKHEADER = 3;
 - }
 - ItemType type = 1;
 - repeated Block blocks = 2;
 - repeated BlockHeader - block_headers = 3;
 - repeated Transaction transactions = 4; - } + message Items {
 + enum ItemType {
 + ERR = 0;
 + TRX = 1;
 + BLOCK = 2;
 + BLOCKHEADER = 3;
 + }
 + ItemType type = 1;
 + repeated Block blocks = 2;
 + repeated BlockHeader + block_headers = 3;
 + repeated Transaction transactions = 4; + } `InventoryItems` contains `type` and `items`. `type`: what type of item. `items`: items in an `InventoryItems`. - message InventoryItems {
 - int32 type = 1;
 - repeated bytes items = 2; - 
} + message InventoryItems {
 + int32 type = 1;
 + repeated bytes items = 2; + 
} message `BlockInventory` contains `type`. `type`: what type of inventory. There are 3 types:`SYNC`, `ADVTISE`, `FETCH`. - // Inventory - message BlockInventory { - enum Type { - SYNC = 0; - ADVTISE = 1; - FETCH = 2; - } + // Inventory + message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } message `BlockId` contains `ids` and `type`. `ids`: the identification of block. @@ -440,13 +440,13 @@ Input, transaction and head block all require signature. `hash`: the hash of block. `number`: the hash and height of block. - message BlockId { - bytes hash = 1; - int64 number = 2; + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; } - repeated BlockId ids = 1; - Type type = 2; - } `ReasonCode`: the type of reason. @@ -467,23 +467,23 @@ Input, transaction and head block all require signature. `RESET` `UNKNOWN` - enum ReasonCode { - REQUESTED = 0; - TCP_ERROR = 1; - BAD_PROTOCOL = 2; - USELESS_PEER = 3; - TOO_MANY_PEERS = 4; - DUPLICATE_PEER = 5; - INCOMPATIBLE_PROTOCOL = 6; - NULL_IDENTITY = 7; - PEER_QUITING = 8; - UNEXPECTED_IDENTITY = 9; - LOCAL_IDENTITY = 10; - PING_TIMEOUT = 11; - USER_REASON = 12; - RESET = 16; - UNKNOWN = 255; - } + enum ReasonCode { + REQUESTED = 0; + TCP_ERROR = 1; + BAD_PROTOCOL = 2; + USELESS_PEER = 3; + TOO_MANY_PEERS = 4; + DUPLICATE_PEER = 5; + INCOMPATIBLE_PROTOCOL = 6; + NULL_IDENTITY = 7; + PEER_QUITING = 8; + UNEXPECTED_IDENTITY = 9; + LOCAL_IDENTITY = 10; + PING_TIMEOUT = 11; + USER_REASON = 12; + RESET = 16; + UNKNOWN = 255; + } message`DisconnectMessage` contains `reason`. `DisconnectMessage`: the message when disconnection occurs. @@ -550,11 +550,11 @@ Input, transaction and head block all require signature. `nodeId`:the ID of nodes. - message Endpoint { - bytes address = 1; - int32 port = 2; - bytes nodeId = 3; - } + message Endpoint { + bytes address = 1; + int32 port = 2; + bytes nodeId = 3; + } `PingMessage`: the message sent from one node to another in the connecting process. message`PingMessage` contains 4 parameters: @@ -563,12 +563,12 @@ Input, transaction and head block all require signature. `version`: the version of the Internet. `timestamp`: the timestamp of message. - message PingMessage { - Endpoint from = 1; - Endpoint to = 2; - int32 version = 3; - int64 timestamp = 4; - } + message PingMessage { + Endpoint from = 1; + Endpoint to = 2; + int32 version = 3; + int64 timestamp = 4; + } `PongMessage`: the message implies that nodes are connected. message`PongMessage` contains 3 parameters: @@ -576,11 +576,11 @@ Input, transaction and head block all require signature. `echo`: `timestamp`: the timestamp of message. - message PongMessage { - Endpoint from = 1; - int32 echo = 2; - int64 timestamp = 3; - } + message PongMessage { + Endpoint from = 1; + int32 echo = 2; + int64 timestamp = 3; + } `FindNeighbours`: the message sent from one node to find another one. message`FindNeighbours` contains 3 parameters: @@ -588,11 +588,11 @@ Input, transaction and head block all require signature. `targetId`: the ID of targeted node. `timestamp`: the timestamp of message. - message FindNeighbours { - Endpoint from = 1; - bytes targetId = 2; - int64 timestamp = 3; - } + message FindNeighbours { + Endpoint from = 1; + bytes targetId = 2; + int64 timestamp = 3; + } `FindNeighbour`: the message replied by the neighbour node. message`Neighbours` contains 3 parameters: @@ -600,10 +600,10 @@ Input, transaction and head block all require signature. `neighbours`: the neighbour node. `timestamp`: the timestamp of message. - message Neighbours { - Endpoint from = 1; - repeated Endpoint neighbours = 2; - int64 timestamp = 3; - } + message Neighbours { + Endpoint from = 1; + repeated Endpoint neighbours = 2; + int64 timestamp = 3; + } # Please check detailed protocol document that may change with the iteration of the program at any time. Please refer to the latest version. From f6639bc6c4d46844b5887a60e49eb34bc757203e Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:01:00 +0800 Subject: [PATCH 05/40] revised --- English version of TRON Protocol document.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index 164ef7c0502..2db6802da08 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -539,7 +539,10 @@ Input, transaction and head block all require signature. message `Return` has only one parameter: `result`: a bool flag. - message `Return` {
 bool result = 1;
} + + message `Return` {
 + bool result = 1; + 
} + The message structure of UDP. From bcb62086ba71bcd913a0a88f62cc8574cabe57d4 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:08:52 +0800 Subject: [PATCH 06/40] revised --- English version of TRON Protocol document.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index 2db6802da08..07dd41b1efc 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -575,7 +575,7 @@ Input, transaction and head block all require signature. `PongMessage`: the message implies that nodes are connected. message`PongMessage` contains 3 parameters: - `from`: whcih node does the message send from. + `from`: whcih node does the message send from. `echo`: `timestamp`: the timestamp of message. From 126bb57eada57cd67605cc385a4f644aca9ef948 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:11:38 +0800 Subject: [PATCH 07/40] revised --- English version of TRON Protocol document.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index 07dd41b1efc..85ffd2c9d0e 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -575,7 +575,7 @@ Input, transaction and head block all require signature. `PongMessage`: the message implies that nodes are connected. message`PongMessage` contains 3 parameters: - `from`: whcih node does the message send from. + `from`: which node does the message send from. `echo`: `timestamp`: the timestamp of message. @@ -587,7 +587,7 @@ Input, transaction and head block all require signature. `FindNeighbours`: the message sent from one node to find another one. message`FindNeighbours` contains 3 parameters: - `from`: whcih node does the message send from. + `from`: which node does the message send from. `targetId`: the ID of targeted node. `timestamp`: the timestamp of message. @@ -599,7 +599,7 @@ Input, transaction and head block all require signature. `FindNeighbour`: the message replied by the neighbour node. message`Neighbours` contains 3 parameters: - `from`: whcih node does the message send from. + `from`: which node does the message send from. `neighbours`: the neighbour node. `timestamp`: the timestamp of message. From 34605c62fc482127d4f181c01a49ba33804f6655 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:25:37 +0800 Subject: [PATCH 08/40] revised --- English version of TRON Protocol document.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index 85ffd2c9d0e..c70978d7047 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -561,7 +561,7 @@ Input, transaction and head block all require signature. `PingMessage`: the message sent from one node to another in the connecting process. message`PingMessage` contains 4 parameters: - `from`: whcih node does the message send from. + `from`: which node does the message send from. `to`: which node will the message send to. `version`: the version of the Internet. `timestamp`: the timestamp of message. @@ -573,7 +573,7 @@ Input, transaction and head block all require signature. int64 timestamp = 4; } - `PongMessage`: the message implies that nodes are connected. + `PongMessage`: the message implies that nodes are connected. message`PongMessage` contains 3 parameters: `from`: which node does the message send from. `echo`: @@ -588,7 +588,7 @@ Input, transaction and head block all require signature. `FindNeighbours`: the message sent from one node to find another one. message`FindNeighbours` contains 3 parameters: `from`: which node does the message send from. - `targetId`: the ID of targeted node. + `targetId`: the ID of targeted node. `timestamp`: the timestamp of message. message FindNeighbours { From 2a380ac98ee63e526ede0799d693cb08578d49f1 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:30:12 +0800 Subject: [PATCH 09/40] revised --- Chinese version of TRON Protocol document.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index 1b70a78c8ac..7acc7b977f3 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -516,8 +516,8 @@ + 网络UDP消息结构。 `Endpoint`:网络中节点信息存储结构. - 消息体`Endpoint` 包含3个参数: - `address`: 节点地址。 + 消息体`Endpoint` 包含3个参数: + `address`:节点地址。 `port`:端口号。 `nodeId`: 节点ID信息。 @@ -554,9 +554,9 @@ } `FindNeighbours`:节点查询相邻节点时所发送的消息。 - 消息体`FindNeighbours` 包含3个参数: + 消息体`FindNeighbours` 包含3个参数: `from`: 消息来自的节点。 - `targetId`: 目标节点的信息。 + `targetId`: 目标节点的信息。 `timestamp`: 消息创建时的时间戳。 message FindNeighbours { From 3f267220d392f9998a10b92a8da9bf9375489073 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:34:04 +0800 Subject: [PATCH 10/40] revised --- Chinese version of TRON Protocol document.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index 7acc7b977f3..75de3193084 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -40,7 +40,7 @@ `address`:验证节点的地址——比如:_“0xu82h…7237”_。 `voteCount`:验证节点所得投票数——比如:_234234_。 `pubKey`:验证节点的公钥——比如:_“0xu82h…7237”_。 - `url`:验证节点的url链接——比如:_“https://www.noonetrust.com”_。 + `url`:验证节点的url链接。 `totalProduce`:验证节点产生的区块数——比如:_2434_。 `totalMissed`:验证节点丢失的区块数——比如:_7_。 `latestBlockNum`:最新的区块高度——比如:_4522_。 @@ -188,8 +188,8 @@ `WitnessCreateContract`包含3种参数: `private_key`:合约的私钥——比如:_“0xu82h…7237”_。 `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 - `url`:合约的url链接——比如:_“https://www.noonetrust.cn”_。 - + `url`:合约的url链接。 + message WitnessCreateContract {
 bytes owner_address = 1;
 bytes private_key = 2;
 @@ -198,7 +198,7 @@ `WitnessUpdateContract`包含2种参数: `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 - `update_url`:合约的url链接——比如:_“https://www.noonetrust.cn”_。 + `update_url`:合约的url链接。 message WitnessUpdateContract { bytes owner_address = 1; From 6d542f8fb146bb302ab70e031c81360ea5c3eef3 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:36:20 +0800 Subject: [PATCH 11/40] revised --- Chinese version of TRON Protocol document.md | 26 +------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index 75de3193084..ea198d63bf8 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -216,7 +216,7 @@ `decav_ratio`:衰减速率。 `vote_score`:合约的评分——比如:_12343_。 `description`:合约的描述——比如:_”trondada”_。 - `url`:合约的url地址链接——比如:_“https://www.noonetrust.cn”_。 + `url`:合约的url地址链接。 message AssetIssueContract {
 bytes owner_address = 1;
 @@ -576,29 +576,5 @@ repeated Endpoint neighbours = 2; int64 timestamp = 3; } - - - - - - - - - - - - - - - - - - - - - - - - # 详细的协议见附属文件。详细协议随着程序的迭代随时都可能发生变化,请以最新的版本为准。 \ No newline at end of file From d62ccb102dbf11ea37504f82fa2a7c4886869471 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 15:40:59 +0800 Subject: [PATCH 12/40] revised --- Chinese version of TRON Protocol document.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index ea198d63bf8..21ebea8480f 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -258,8 +258,9 @@ SUCESS = 0; FAILED = 1; } - int64 fee = 1; - code ret = 2; + int64 fee = 1; + code ret = 2; + } + 每一个交易还包含多个输入与多个输出,以及其他一些相关属性。其中交易内的输入,交易本身,区块头均需签名。 From 649dfbfddb7a56cdd2321c7428ca05e9a68a7e23 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Tue, 10 Apr 2018 16:54:22 +0800 Subject: [PATCH 13/40] improve: add ref_block_num and ref_block_hash --- core/Tron.proto | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index f4d46dc8e53..d6df9a2029d 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -97,7 +97,9 @@ message Transaction { } message raw { - TransactionType type = 2; + TransactionType type = 1 + int64 ref_block_num = 3; + bytes ref_block_hash = 4; int64 expiration = 8; bytes data = 10; repeated Contract contract = 11; From 8c635e5877d71277239646b27d0218b9541339a3 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Tue, 10 Apr 2018 17:01:20 +0800 Subject: [PATCH 14/40] improve: modified the seq num and fix build error --- core/Tron.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index d6df9a2029d..8aa587249eb 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -97,14 +97,14 @@ message Transaction { } message raw { - TransactionType type = 1 + TransactionType type = 1; int64 ref_block_num = 3; bytes ref_block_hash = 4; int64 expiration = 8; bytes data = 10; repeated Contract contract = 11; - bytes scripts = 16; - int64 timestamp = 17; + bytes scripts = 12; + int64 timestamp = 14; } raw raw_data = 1; From 23a5587f27327c9fdd17f5e0c5d704d11d669fc3 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 20:37:25 +0800 Subject: [PATCH 15/40] revised --- Chinese version of TRON Protocol document.md | 155 +++++++++++++-- English version of TRON Protocol document.md | 188 +++++++++++++++---- 2 files changed, 292 insertions(+), 51 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index 21ebea8480f..8f0c50ae40d 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -479,41 +479,158 @@ `from`请:求建立连接的节点。 `version`:建立连接的节点。 -+ 钱包服务RPC ++ 钱包服务RPC和区块链浏览器。 `Wallet`钱包服务包含多个RPC。 __`Getbalance`__:获取`Account`的余额。 __`CreatTransaction`__:通过`TransferContract`创建交易。 __`BroadcastTransaction`__:广播`Transaction`。 __`CreateAccount`__:通过`AccountCreateContract`创建账户。 - __`CreatAssetContract`__:通过`AssetIssueContract`发布一个资产。 + __`CreatAssetIssue`__:通过`AssetIssueContract`发布一个资产。 + __`ListAccounts`__:通过`ListAccounts`查看账户列表。 + __`UpdateAccount`__:通过`UpdateAccountContract`发布一个资产。 + __`VoteWitnessAccount`__:通过`VoteWitnessContract`发布一个资产。 + __`WitnessList`__:通过`WitnessList`查看见证节点列表。 + __`UpdateWitness`__:通过`WitnessUpdateContract`发布一个资产。 + __`CreateWitness`__:通过`WitnessCreateContract`发布一个资产。 + __`TransferAsset`__:通过`TransferAssetContract`发布一个资产。 + __`ParticipateAssetIssue`__:通过`ParticipateAssetIssueContract`发布一个资产。 + __`ListNodes`__:通过`ListNodes`查看节点列表。 + __`GetAssetIssueList`__:通过`GetAssetIssueList`查看资产发布节点列表。 + __`GetAssetIssueByAccount`__:通过`Account`获取发行资产。 + __`GetAssetIssueByName`__:通过`Name`获取发行资产。 + __`GetNowBlock`__:获取区块。 + __`GetBlockByNum`__:获取块号获取区块。 + __`TotalTransaction`__:查看总交易量。 + + service Wallet { + + rpc GetAccount (Account) returns (Account) { + + }; + + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc UpdateAccount (AccountUpdateContract) returns (Transaction) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc WitnessList (EmptyMessage) returns (WitnessList) { + + }; + + rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc TransferAsset (TransferAssetContract) returns (Transaction) { + + } + + rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { + + } + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } + rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + + } + rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { + + } + rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) { + + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + + } + rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { + + } + }; - service Wallet {

 - - rpc GetBalance (Account) returns (Account) {

 + `AccountList`: 区块链浏览器中的账户列表。 + 消息体 `AccountList` 包含1个参数: + `account`: + + message AccountList { + repeated Account accounts = 1; + } + + `WitnessList`:区块链浏览器中的见证节点列表。 + 消息体 `WitnessList` 包含1个参数: + `witnesses`: - };
 - rpc CreateTransaction (TransferContract) returns (Transaction) {

 + message WitnessList { + repeated Witness witnesses = 1; + } + + `AssetIssueList`:区块链浏览器中的发布资产列表。 + 消息体 `AssetIssueList` 包含1个参数: + `assetIssue`: - };

 - rpc BroadcastTransaction (Transaction) returns (Return) {

 + message AssetIssueList { + repeated AssetIssueContract assetIssue = 1; + } - };

 - rpc CreateAccount(AccountCreateContract) returns (Transaction) {

 + + `NodeList`: 分布节点图中的节点列表。 + 消息体 `NodeList` 包含1个参数: + `nodes`: - };

 rpc CreateAssetIssue(AssetIssueContract) returns (Transaction) {

 + message NodeList { + repeated Node nodes = 1; + } - };

 + `Address`: 节点地址。 + 消息体`Address` 包含2个参数: + `host`:节点所有者。 + `port`:节点的端口号。 - }; - - + message Address { + bytes host = 1; + int32 port = 2; + } + + 消息体`Return`只含有一个参数: `result`: 布尔表类型标志位。 - message `Return` {
 - bool result = 1;
 - } + message `Return` {
 + bool result = 1;
 + } + + 网络UDP消息结构。 `Endpoint`:网络中节点信息存储结构. diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md index c70978d7047..9e7b36f0bc9 100644 --- a/English version of TRON Protocol document.md +++ b/English version of TRON Protocol document.md @@ -496,7 +496,7 @@ Input, transaction and head block all require signature. -+ Wallet Service RPC ++ Wallet Service RPC and blockchain explorer `Wallet` service contains several RPCs. __`GetBalance`__ : @@ -507,42 +507,164 @@ Input, transaction and head block all require signature. Broadcast a `Transaction`. A `Return` will be returned indicating if broadcast is success of not. __`CreateAccount`__ : Create an account by giving a `AccountCreateContract`. - __`CreatAssetContract`__ : - Issue an asset by giving a `AssetIssueContract`. - - service Wallet {

 + __`CreatAssetIssue`__ : + Issue an asset by giving a `AssetIssueContract`. + __`ListAccounts`__: + Check out the list of accounts by giving a `ListAccounts`. + __`UpdateAccount`__: + Issue an asset by giving a `UpdateAccountContract`. + __`VoteWitnessAccount`__: + Issue an asset by giving a `VoteWitnessContract`. + __`WitnessList`__: + Check out the list of witnesses by giving a `WitnessList`. + __`UpdateWitness`__: + Issue an asset by giving a `WitnessUpdateContract`. + __`CreateWitness`__: + Issue an asset by giving a `WitnessCreateContract`. + __`TransferAsset`__: + Issue an asset by giving a `TransferAssetContract`. + __`ParticipateAssetIssue`__: + Issue an asset by giving a `ParticipateAssetIssueContract`. + __`ListNodes`__: + Check out the list of nodes by giving a `ListNodes`. + __`GetAssetIssueList`__: + Get the list of issue asset by giving a `GetAssetIssueList`. + __`GetAssetIssueByAccount`__: + Get issue asset by giving a `Account`. + __`GetAssetIssueByName`__: + Get issue asset by giving a`Name`. + __`GetNowBlock`__: + Get block. + __`GetBlockByNum`__: + Get block by block number. + __`TotalTransaction`__: + Check out the total transaction. + + service Wallet { - rpc GetBalance (Account) returns (Account) {

 - - };
 - rpc CreateTransaction (TransferContract) returns - (Transaction) {

 - - };

 - - rpc BroadcastTransaction (Transaction) returns (Return) {

 - - };

 - - rpc CreateAccount(AccountCreateContract) returns - (Transaction) {

 + rpc GetAccount (Account) returns (Account) { + + }; + + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc UpdateAccount (AccountUpdateContract) returns (Transaction) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc TransferAsset (TransferAssetContract) returns (Transaction) { + + } + + rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { + + } + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } + rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + + } + rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { + + } + rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) { + + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + + } + rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { + + } + }; + + `AccountList`: the list of acounts in the blockchain explorer. + message `AccountList` contains one parameter: + `account`: + + message AccountList { + repeated Account accounts = 1; + } - };

 - - rpc CreateAssetIssue(AssetIssueContract) returns - (Transaction) {

 - - };

 - - }; - - + `WitnessList`: the list of witnesses in the blockchain explorer. + message `WitnessList` contains one parameter: + `witnesses`: + + message WitnessList { + repeated Witness witnesses = 1; + } + + `AssetIssueList`: the list of issue asset in the blockchain explorer. + message `AssetIssueList` contains one parameter: + `assetIssue`: + + message AssetIssueList { + repeated AssetIssueContract assetIssue = 1; + } + + `NodeList`: the list of nodes in the node distribution map. + message `NodeList` contains one parameter: + `nodes`: + + message NodeList { + repeated Node nodes = 1; + } + + `Address`: the address of nodes. + message`Address` contains 2 parameters: + `host`: the host of nodes. + `port`: the port number of nodes. + + message Address { + bytes host = 1; + int32 port = 2; + } + message `Return` has only one parameter: `result`: a bool flag. - message `Return` {
 - bool result = 1; - 
} + message `Return` {
 + bool result = 1; + 
} + The message structure of UDP. @@ -609,4 +731,6 @@ Input, transaction and head block all require signature. int64 timestamp = 3; } + + # Please check detailed protocol document that may change with the iteration of the program at any time. Please refer to the latest version. From 8a45295f8f7a591a5222a5f9bfdbc78ca5f8c6b6 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 20:43:46 +0800 Subject: [PATCH 16/40] revised --- Chinese version of TRON Protocol document.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index 8f0c50ae40d..d19836cb83a 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -500,7 +500,7 @@ __`GetAssetIssueByAccount`__:通过`Account`获取发行资产。 __`GetAssetIssueByName`__:通过`Name`获取发行资产。 __`GetNowBlock`__:获取区块。 - __`GetBlockByNum`__:获取块号获取区块。 + __`GetBlockByNum`__:根据块号获取区块。 __`TotalTransaction`__:查看总交易量。 service Wallet { From 159e88793c338da8de74231b07c4f49b506b2f01 Mon Sep 17 00:00:00 2001 From: Darcy Date: Tue, 10 Apr 2018 20:47:40 +0800 Subject: [PATCH 17/40] revised --- Chinese version of TRON Protocol document.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md index d19836cb83a..cc1bd2d68d9 100644 --- a/Chinese version of TRON Protocol document.md +++ b/Chinese version of TRON Protocol document.md @@ -633,8 +633,8 @@ + 网络UDP消息结构。 - `Endpoint`:网络中节点信息存储结构. - 消息体`Endpoint` 包含3个参数: + `Endpoint`:网络中节点信息存储结构. + 消息体`Endpoint` 包含3个参数: `address`:节点地址。 `port`:端口号。 `nodeId`: 节点ID信息。 @@ -659,7 +659,7 @@ int64 timestamp = 4; } - `PongMessage`:连接建立成功时的回复消息。 + `PongMessage`:连接建立成功时的回复消息。 消息体`PongMessage` 包含3个参数: `from`:消息来自的节点。 `echo`: @@ -683,11 +683,11 @@ int64 timestamp = 3; } - `Neighbour`:相邻接点回复消息。 + `Neighbour`:相邻接点回复消息。 消息体`Neighbours` 包含3个参数: `from`: 消息来自的节点。 `neighbours`: 相邻节点。 - `timestamp`: 消息体创建时的时间戳。 + `timestamp`: 消息创建时的时间戳。 message Neighbours { Endpoint from = 1; From 08c6c90fad1743d0652c2bd9f16878c242aba7ee Mon Sep 17 00:00:00 2001 From: huzhenyuan Date: Wed, 11 Apr 2018 17:13:58 +0800 Subject: [PATCH 18/40] add GetDynamicProperties rpc api --- api/api.proto | 3 +++ core/Tron.proto | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/api/api.proto b/api/api.proto index 03419d235d5..3d6c0ad0f8a 100644 --- a/api/api.proto +++ b/api/api.proto @@ -82,6 +82,9 @@ service Wallet { } rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { + } + rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { + } }; // the api of tron's db diff --git a/core/Tron.proto b/core/Tron.proto index 7339733487a..b5914a3d33f 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -182,6 +182,11 @@ message Items { repeated Transaction transactions = 4; } +// DynamicProperties +message DynamicProperties { + int64 last_solidity_block_num = 1; +} + enum ReasonCode { REQUESTED = 0; TCP_ERROR = 1; From 169058aca47849fa61ae727e176c4090c171f631 Mon Sep 17 00:00:00 2001 From: ashu Date: Thu, 12 Apr 2018 12:06:22 +0800 Subject: [PATCH 19/40] add tron grpc proxy --- api/api.proto | 15 +++++++++++---- core/Contract.proto | 2 +- core/Discover.proto | 2 +- core/Tron.proto | 3 +-- core/TronInventoryItems.proto | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/api/api.proto b/api/api.proto index 3d6c0ad0f8a..7c0474d0c8e 100644 --- a/api/api.proto +++ b/api/api.proto @@ -3,14 +3,20 @@ package protocol; import "core/Tron.proto"; import "core/Contract.proto"; +import "google/api/annotations.proto"; + option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/api"; +option go_package = "github.com/tronprotocol/grpc-gateway/api"; service Wallet { rpc GetAccount (Account) returns (Account) { + option (google.api.http) = { + post: "v1/account" + body: "*" + }; }; @@ -23,6 +29,10 @@ service Wallet { }; rpc ListAccounts (EmptyMessage) returns (AccountList) { + option (google.api.http) = { + post: "/v1/account/list" + body: "*" + }; }; @@ -82,9 +92,6 @@ service Wallet { } rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { - } - rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { - } }; // the api of tron's db diff --git a/core/Contract.proto b/core/Contract.proto index a00c82eec58..37a210ecc58 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -19,7 +19,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Contract"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; +option go_package = "github.com/tronprotocol/grpc-gateway/core"; import "core/Tron.proto"; diff --git a/core/Discover.proto b/core/Discover.proto index ac45a30364a..cba982a18b1 100644 --- a/core/Discover.proto +++ b/core/Discover.proto @@ -5,7 +5,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Discover"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; +option go_package = "github.com/tronprotocol/grpc-gateway/core"; message Endpoint { bytes address = 1; diff --git a/core/Tron.proto b/core/Tron.proto index b5914a3d33f..30c16b7b568 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -8,8 +8,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Protocol"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; - +option go_package = "github.com/tronprotocol/grpc-gateway/core"; enum AccountType { Normal = 0; diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto index f630ffad598..a82d2de4552 100644 --- a/core/TronInventoryItems.proto +++ b/core/TronInventoryItems.proto @@ -4,7 +4,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; +option go_package = "github.com/tronprotocol/grpc-gateway/core"; message InventoryItems { int32 type = 1; From 72101540437d52c1d36312cdc3e28f0ecb9030bc Mon Sep 17 00:00:00 2001 From: ashu Date: Thu, 12 Apr 2018 12:36:49 +0800 Subject: [PATCH 20/40] add swagger generate srcipt and swagger definitions --- api/api.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api.proto b/api/api.proto index 7c0474d0c8e..5cdfa8bf3da 100644 --- a/api/api.proto +++ b/api/api.proto @@ -14,7 +14,7 @@ service Wallet { rpc GetAccount (Account) returns (Account) { option (google.api.http) = { - post: "v1/account" + post: "/v1/account" body: "*" }; From b33bfdd91c224f748148a7411b70e2f34d27c432 Mon Sep 17 00:00:00 2001 From: ashu Date: Thu, 12 Apr 2018 17:35:12 +0800 Subject: [PATCH 21/40] config http url for grpc --- api/api.proto | 98 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 22 deletions(-) diff --git a/api/api.proto b/api/api.proto index 5cdfa8bf3da..d4650006d07 100644 --- a/api/api.proto +++ b/api/api.proto @@ -14,84 +14,138 @@ service Wallet { rpc GetAccount (Account) returns (Account) { option (google.api.http) = { - post: "/v1/account" - body: "*" - }; + post: "/wallet/getaccount" + body: "*" + }; }; rpc CreateTransaction (TransferContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createtransaction" + body: "*" + }; }; rpc BroadcastTransaction (Transaction) returns (Return) { - + option (google.api.http) = { + post: "/wallet/broadcasttransaction" + body: "*" + }; }; rpc ListAccounts (EmptyMessage) returns (AccountList) { option (google.api.http) = { - post: "/v1/account/list" + post: "/wallet/listaccount" body: "*" }; }; rpc UpdateAccount (AccountUpdateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/updateaccount" + body: "*" + }; }; rpc CreateAccount (AccountCreateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createaccount" + body: "*" + }; }; rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/votewitnessaccount" + body: "*" + }; }; rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createassetissue" + body: "*" + }; }; rpc ListWitnesses (EmptyMessage) returns (WitnessList) { - + option (google.api.http) = { + post: "/wallet/listwitnesses" + body: "*" + }; }; rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/updatewitness" + body: "*" + }; }; rpc CreateWitness (WitnessCreateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createwitness" + body: "*" + }; }; rpc TransferAsset (TransferAssetContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/transferasset" + body: "*" + }; } rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/participateassetissue" + body: "*" + }; } rpc ListNodes (EmptyMessage) returns (NodeList) { - + option (google.api.http) = { + post: "/wallet/listnodes" + body: "*" + }; } rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { - + option (google.api.http) = { + post: "/wallet/getassetissuelist" + body: "*" + }; } rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { - + option (google.api.http) = { + post: "/wallet/getassetissuebyaccount" + body: "*" + }; } rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) { - + option (google.api.http) = { + post: "/wallet/getassetissuebyname" + body: "*" + }; } rpc GetNowBlock (EmptyMessage) returns (Block) { - + option (google.api.http) = { + post: "/wallet/getnowblock" + body: "*" + }; } rpc GetBlockByNum (NumberMessage) returns (Block) { - + option (google.api.http) = { + post: "/wallet/getblockbynum" + body: "*" + }; } rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { - + option (google.api.http) = { + post: "/wallet/totaltransaction" + body: "*" + }; } }; // the api of tron's db From 65314a5e769f928ff0c8e981b653ba10b3afa5c1 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 11:50:42 +0800 Subject: [PATCH 22/40] add googleapis proto file into protoc include --- .travis.yml | 1 + install-googleapis.sh | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100755 install-googleapis.sh diff --git a/.travis.yml b/.travis.yml index 3f1e4c4709b..0b642642c05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ sudo: false before_install: - bash install-protobuf.sh + - bash install-googleapis.sh # check what has been installed by listing contents of protobuf folder before_script: diff --git a/install-googleapis.sh b/install-googleapis.sh new file mode 100755 index 00000000000..5767d7ab909 --- /dev/null +++ b/install-googleapis.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e +wget http://central.maven.org/maven2/com/google/api/grpc/googleapis-common-protos/0.0.3/googleapis-common-protos-0.0.3.jar +jar xvf googleapis-common-protos-0.0.3.jar -C $HOME/protobuf/include/ +ls -l + + + From 623ceea36319abd47de35cbd7b7d9667904da978 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 12:07:37 +0800 Subject: [PATCH 23/40] fix install-googleapis --- install-googleapis.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install-googleapis.sh b/install-googleapis.sh index 5767d7ab909..284ed6e58a2 100755 --- a/install-googleapis.sh +++ b/install-googleapis.sh @@ -1,7 +1,8 @@ #!/bin/sh set -e wget http://central.maven.org/maven2/com/google/api/grpc/googleapis-common-protos/0.0.3/googleapis-common-protos-0.0.3.jar -jar xvf googleapis-common-protos-0.0.3.jar -C $HOME/protobuf/include/ +jar xvf googleapis-common-protos-0.0.3.jar +cp -r google/ $HOME/protobuf/include/ ls -l From 8ead80e7cd24c544140b1faaf81bbc510215f586 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 12:22:12 +0800 Subject: [PATCH 24/40] add go proto ci --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0b642642c05..c7bc9964c35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,8 @@ before_script: # let's use protobuf script: - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - $HOME/protobuf/bin/protoc --go_out=./ ./core/*.proto + - $HOME/protobuf/bin/protoc --go_out=./ ./api/*.proto + - $HOME/protobuf/bin/protoc --grpc-gateway_out=logtostderr=true:./ ./api/*.proto + - ls -l \ No newline at end of file From 84e3f19affe5f3f0002569d19b0a36ed9338a243 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 12:41:17 +0800 Subject: [PATCH 25/40] add protoc-gen-go plugin --- install-protobuf.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-protobuf.sh b/install-protobuf.sh index 29e5536ee6d..b3a8cb5cbb2 100755 --- a/install-protobuf.sh +++ b/install-protobuf.sh @@ -2,8 +2,8 @@ set -e # check to see if protobuf folder is empty if [ ! -d "$HOME/protobuf/lib" ]; then - wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz - tar -xzvf protobuf-java-3.5.1.tar.gz + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz + tar -xzvf protobuf-all-3.5.1.tar.gz cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install else echo "Using cached directory." From d536ddacc5bdc10be283e353df941d8487f708b2 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 12:55:27 +0800 Subject: [PATCH 26/40] rm cached directory --- install-protobuf.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install-protobuf.sh b/install-protobuf.sh index b3a8cb5cbb2..76f02aa744c 100755 --- a/install-protobuf.sh +++ b/install-protobuf.sh @@ -1,6 +1,7 @@ #!/bin/sh set -e # check to see if protobuf folder is empty +rm -rf $HOME/protobuf/lib if [ ! -d "$HOME/protobuf/lib" ]; then wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz tar -xzvf protobuf-all-3.5.1.tar.gz From 21fba07965e7bb5a4b46492fb13125298a07d1ba Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 13:02:43 +0800 Subject: [PATCH 27/40] add protoc-go-gen dependencies --- .travis.yml | 6 +++--- install-googleapis.sh | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7bc9964c35..71d8f70d57e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,8 @@ before_script: # let's use protobuf script: - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto - - $HOME/protobuf/bin/protoc --go_out=./ ./core/*.proto - - $HOME/protobuf/bin/protoc --go_out=./ ./api/*.proto - - $HOME/protobuf/bin/protoc --grpc-gateway_out=logtostderr=true:./ ./api/*.proto + - $HOME/protobuf/bin/protoc I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./core/*.proto + - $HOME/protobuf/bin/protoc I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./api/*.proto + - $HOME/protobuf/bin/protoc I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:./ ./api/*.proto - ls -l \ No newline at end of file diff --git a/install-googleapis.sh b/install-googleapis.sh index 284ed6e58a2..0d44f6108d1 100755 --- a/install-googleapis.sh +++ b/install-googleapis.sh @@ -1,5 +1,10 @@ #!/bin/sh set -e + +go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway +go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger +go get -u github.com/golang/protobuf/protoc-gen-go + wget http://central.maven.org/maven2/com/google/api/grpc/googleapis-common-protos/0.0.3/googleapis-common-protos-0.0.3.jar jar xvf googleapis-common-protos-0.0.3.jar cp -r google/ $HOME/protobuf/include/ From 48a994cd9dc2435f7243c0f671db4ec4bd77bdb3 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 13:55:22 +0800 Subject: [PATCH 28/40] fix go gen script --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71d8f70d57e..34fa71b3d15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,8 @@ before_script: # let's use protobuf script: - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto - - $HOME/protobuf/bin/protoc I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./core/*.proto - - $HOME/protobuf/bin/protoc I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./api/*.proto - - $HOME/protobuf/bin/protoc I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:./ ./api/*.proto + - $HOME/protobuf/bin/protoc -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./core/*.proto + - $HOME/protobuf/bin/protoc -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./api/*.proto + - $HOME/protobuf/bin/protoc -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:./ ./api/*.proto - ls -l \ No newline at end of file From 87c23fbe4fddf650f08a755c1d0df87f80e8fd1d Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Fri, 13 Apr 2018 14:05:20 +0800 Subject: [PATCH 29/40] add get Transaction api. --- api/api.proto | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/api/api.proto b/api/api.proto index 3d6c0ad0f8a..af48c792dff 100644 --- a/api/api.proto +++ b/api/api.proto @@ -67,6 +67,9 @@ service Wallet { } rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + } + rpc GetAssetIssueListBy (EmptyMessage) returns (AssetIssueList) { + } rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { @@ -80,10 +83,23 @@ service Wallet { rpc GetBlockByNum (NumberMessage) returns (Block) { } + rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { + + } + //get transaction rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { } - rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { + rpc getTransactionById (BytesMessage) returns (Transaction) { + + } + rpc getTransactionsByTimestamp (TimeMessage) returns (TransactionList) { + + } + rpc getTransactionsFromThis (Account) returns (TransactionList) { + + } + rpc getTransactionsToThis (Account) returns (NumberMessage) { } }; @@ -113,6 +129,12 @@ message WitnessList { message AssetIssueList { repeated AssetIssueContract assetIssue = 1; } +message BlockList { + repeated Block block = 1; +} +message TransactionList { + repeated Transaction transaction = 1; +} // Gossip node list message NodeList { @@ -137,4 +159,8 @@ message NumberMessage { } message BytesMessage { bytes value = 1; +} +message TimeMessage { + int64 beginInMilliseconds = 1; + int64 endInMilliseconds = 2; } \ No newline at end of file From acc5c20da2274082e03ce3ffaea3dd04b6aa0dab Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Fri, 13 Apr 2018 14:06:56 +0800 Subject: [PATCH 30/40] add get AssetIssueList by Timestamp api. --- api/api.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api.proto b/api/api.proto index af48c792dff..6f42e98fcf9 100644 --- a/api/api.proto +++ b/api/api.proto @@ -68,7 +68,7 @@ service Wallet { rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { } - rpc GetAssetIssueListBy (EmptyMessage) returns (AssetIssueList) { + rpc GetAssetIssueListByTimestamp (NumberMessage) returns (AssetIssueList) { } rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { From 4743ea0f03cde9b880483d65c8422bcaaa562353 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 14:12:00 +0800 Subject: [PATCH 31/40] fix install-protobuf.sh --- install-protobuf.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install-protobuf.sh b/install-protobuf.sh index 76f02aa744c..29e5536ee6d 100755 --- a/install-protobuf.sh +++ b/install-protobuf.sh @@ -1,10 +1,9 @@ #!/bin/sh set -e # check to see if protobuf folder is empty -rm -rf $HOME/protobuf/lib if [ ! -d "$HOME/protobuf/lib" ]; then - wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz - tar -xzvf protobuf-all-3.5.1.tar.gz + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz + tar -xzvf protobuf-java-3.5.1.tar.gz cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install else echo "Using cached directory." From 950a9b9f6fe37e65ba9a78c376ff38d2e440c9b6 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 15:01:22 +0800 Subject: [PATCH 32/40] disable travis cache --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 34fa71b3d15..cc1be5a19f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,5 @@ language: ruby -cache: - directories: - - $HOME/protobuf - sudo: false before_install: From 23f0cce5cb881f0d25baf544bcdc51df42a1f20d Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 15:09:33 +0800 Subject: [PATCH 33/40] change protobuf-java to protobuf-all for protoc --- .travis.yml | 4 ++++ install-protobuf.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cc1be5a19f3..34fa71b3d15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: ruby +cache: + directories: + - $HOME/protobuf + sudo: false before_install: diff --git a/install-protobuf.sh b/install-protobuf.sh index 29e5536ee6d..6f69d20ad02 100755 --- a/install-protobuf.sh +++ b/install-protobuf.sh @@ -2,7 +2,7 @@ set -e # check to see if protobuf folder is empty if [ ! -d "$HOME/protobuf/lib" ]; then - wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz tar -xzvf protobuf-java-3.5.1.tar.gz cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install else From aeffcf9298c7b9b02ba1e68f0ea5ac1e9a079bb8 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 15:14:05 +0800 Subject: [PATCH 34/40] update readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c04fbf6968a..98c21fe1ad8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,6 @@ the protocol of tron including api and message. -java-tron and wallet-cli +java-tron, wallet-cli and grpc-gateway git subtree pull --prefix src/main/protos/ protocol master From 38c1d2e8b8c26a666eb532be044e7b53bfef20c4 Mon Sep 17 00:00:00 2001 From: ashu Date: Fri, 13 Apr 2018 15:22:26 +0800 Subject: [PATCH 35/40] fix install-protobuf.sh --- install-protobuf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-protobuf.sh b/install-protobuf.sh index 6f69d20ad02..b3a8cb5cbb2 100755 --- a/install-protobuf.sh +++ b/install-protobuf.sh @@ -3,7 +3,7 @@ set -e # check to see if protobuf folder is empty if [ ! -d "$HOME/protobuf/lib" ]; then wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz - tar -xzvf protobuf-java-3.5.1.tar.gz + tar -xzvf protobuf-all-3.5.1.tar.gz cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install else echo "Using cached directory." From 2dbee3b51e504aa32ebf0cab92d1c309cf51fa83 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Fri, 13 Apr 2018 17:43:57 +0800 Subject: [PATCH 36/40] add WalletSolidity api service. --- api/api.proto | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/api/api.proto b/api/api.proto index 6f42e98fcf9..de24fa70fdb 100644 --- a/api/api.proto +++ b/api/api.proto @@ -67,6 +67,43 @@ service Wallet { } rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + } + rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { + + } + rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) { + + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + + } + rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { + + } +}; + +service WalletSolidity { + + rpc GetAccount (Account) returns (Account) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } + rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + } rpc GetAssetIssueListByTimestamp (NumberMessage) returns (AssetIssueList) { From a5e544c939c713ae2d53d571ac75ebfd55a012fc Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 16 Apr 2018 14:45:48 +0800 Subject: [PATCH 37/40] fix:change go_package. --- api/api.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api.proto b/api/api.proto index 6c85113e38a..8fc2ccbd596 100644 --- a/api/api.proto +++ b/api/api.proto @@ -8,7 +8,7 @@ import "google/api/annotations.proto"; option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/api"; +option go_package = "github.com/tronprotocol/grpc-gateway/api"; service Wallet { From 2f7ae0b8cc086d90bbbcb4bbb51a6555bc5513fc Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 16 Apr 2018 16:41:18 +0800 Subject: [PATCH 38/40] feature:add Datebase api Service. --- api/api.proto | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/api/api.proto b/api/api.proto index d4650006d07..54096b1343d 100644 --- a/api/api.proto +++ b/api/api.proto @@ -148,11 +148,29 @@ service Wallet { }; } }; + // the api of tron's db service Database { + // for tapos + rpc getBlockReference (EmptyMessage) returns (BlockReference) { + + } + rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { + + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + + } }; +message BlockReference { + int64 block_num = 1; + bytes block_hash = 2; +} + // the api of tron's network such as node list. service Network { From 949844879adbe29cdb7df2a492a94aa299721978 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 16 Apr 2018 16:53:53 +0800 Subject: [PATCH 39/40] feature: merge master to this. --- api/api.proto | 9 --------- 1 file changed, 9 deletions(-) diff --git a/api/api.proto b/api/api.proto index f8ea6d8b80c..66aa6d53948 100644 --- a/api/api.proto +++ b/api/api.proto @@ -147,12 +147,6 @@ service Wallet { body: "*" }; } - rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { - option (google.api.http) = { - post: "/wallet/getdynamicproperties" - body: "*" - }; - } }; @@ -190,9 +184,6 @@ service WalletSolidity { } rpc GetBlockByNum (NumberMessage) returns (Block) { - } - rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { - } //get transaction rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { From 130f5a297818a2105e75e7bc56675c9fa4411888 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Wed, 18 Apr 2018 16:45:44 +0800 Subject: [PATCH 40/40] modify reason code --- core/Tron.proto | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 30c16b7b568..d9800a4f710 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -187,21 +187,21 @@ message DynamicProperties { } enum ReasonCode { - REQUESTED = 0; - TCP_ERROR = 1; - BAD_PROTOCOL = 2; - USELESS_PEER = 3; - TOO_MANY_PEERS = 4; - DUPLICATE_PEER = 5; - INCOMPATIBLE_PROTOCOL = 6; - NULL_IDENTITY = 7; - PEER_QUITING = 8; - UNEXPECTED_IDENTITY = 9; - LOCAL_IDENTITY = 10; - PING_TIMEOUT = 11; - USER_REASON = 12; - RESET = 16; - UNKNOWN = 255; + REQUESTED = 0x00; + TCP_ERROR = 0x01; + BAD_PROTOCOL = 0x02; + USELESS_PEER = 0x03; + TOO_MANY_PEERS = 0x04; + DUPLICATE_PEER = 0x05; + INCOMPATIBLE_PROTOCOL = 0x06; + NULL_IDENTITY = 0x07; + PEER_QUITING = 0x08; + UNEXPECTED_IDENTITY = 0x09; + LOCAL_IDENTITY = 0x0A; + PING_TIMEOUT = 0x0B; + USER_REASON = 0x10; + RESET = 0x11; + UNKNOWN = 0xFF; } message DisconnectMessage {