From b7527ad4acd1985369331d36484fccc9bccee6fb Mon Sep 17 00:00:00 2001 From: chanhsu001 Date: Thu, 2 Sep 2021 18:59:47 +0800 Subject: [PATCH] refactor(rpc): change struct from "TxPoolVerbosity" to "TxPoolEntries", "TxVerbosity" to "TxPoolEntr --- devtools/doc/rpc.py | 4 +- rpc/README.md | 74 +++++++++++++++++----------------- util/jsonrpc-types/src/lib.rs | 4 +- util/jsonrpc-types/src/pool.rs | 26 ++++++------ 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/devtools/doc/rpc.py b/devtools/doc/rpc.py index 21bd3a4db7..01816a7f2f 100755 --- a/devtools/doc/rpc.py +++ b/devtools/doc/rpc.py @@ -719,8 +719,8 @@ def collect(self): self.collect_type('ckb_jsonrpc_types/enum.PoolTransactionReject.html') # Referenced by RawTxPool self.collect_type('ckb_jsonrpc_types/struct.TxPoolIds.html') - self.collect_type('ckb_jsonrpc_types/struct.TxPoolVerbosity.html') - self.collect_type('ckb_jsonrpc_types/struct.TxVerbosity.html') + self.collect_type('ckb_jsonrpc_types/struct.TxPoolEntries.html') + self.collect_type('ckb_jsonrpc_types/struct.TxPoolEntry.html') self.types.sort(key=lambda t: t.name) def collect_type(self, path): diff --git a/rpc/README.md b/rpc/README.md index d54a2ea610..51bc4652a4 100644 --- a/rpc/README.md +++ b/rpc/README.md @@ -141,11 +141,11 @@ The crate `ckb-rpc`'s minimum supported rustc version is 1.51.0. * [Type `TransactionTemplate`](#type-transactiontemplate) * [Type `TransactionView`](#type-transactionview) * [Type `TransactionWithStatus`](#type-transactionwithstatus) + * [Type `TxPoolEntries`](#type-txpoolentries) + * [Type `TxPoolEntry`](#type-txpoolentry) * [Type `TxPoolIds`](#type-txpoolids) * [Type `TxPoolInfo`](#type-txpoolinfo) - * [Type `TxPoolVerbosity`](#type-txpoolverbosity) * [Type `TxStatus`](#type-txstatus) - * [Type `TxVerbosity`](#type-txverbosity) * [Type `U256`](#type-u256) * [Type `Uint128`](#type-uint128) * [Type `Uint32`](#type-uint32) @@ -3993,7 +3993,7 @@ The ratio which numerator and denominator are both 256-bit unsigned integers. All transactions in tx-pool. -`RawTxPool` is equivalent to [`TxPoolIds`](#type-txpoolids) `|` [`TxPoolVerbosity`](#type-txpoolverbosity). +`RawTxPool` is equivalent to [`TxPoolIds`](#type-txpoolids) `|` [`TxPoolEntries`](#type-txpoolentries). ### Type `RemoteNode` @@ -4378,6 +4378,40 @@ The JSON view of a transaction as well as its status. * `tx_status`: [`TxStatus`](#type-txstatus) - The Transaction status. +### Type `TxPoolEntries` + +Tx-pool entries object + +#### Fields + +`TxPoolEntries` is a JSON object with the following fields. + +* `pending`: `{ [ key:` [`H256`](#type-h256) `]: ` [`TxPoolEntry`](#type-txpoolentry) `}` - Pending tx verbose info + +* `proposed`: `{ [ key:` [`H256`](#type-h256) `]: ` [`TxPoolEntry`](#type-txpoolentry) `}` - Proposed tx verbose info + + +### Type `TxPoolEntry` + +Transaction entry info + +#### Fields + +`TxPoolEntry` is a JSON object with the following fields. + +* `cycles`: [`Uint64`](#type-uint64) - Consumed cycles. + +* `size`: [`Uint64`](#type-uint64) - The transaction serialized size in block. + +* `fee`: [`Capacity`](#type-capacity) - The transaction fee. + +* `ancestors_size`: [`Uint64`](#type-uint64) - Size of in-tx-pool ancestor transactions + +* `ancestors_cycles`: [`Uint64`](#type-uint64) - Cycles of in-tx-pool ancestor transactions + +* `ancestors_count`: [`Uint64`](#type-uint64) - Number of in-tx-pool ancestor transactions + + ### Type `TxPoolIds` Array of transaction ids @@ -4428,19 +4462,6 @@ Transaction pool information. * `last_txs_updated_at`: [`Timestamp`](#type-timestamp) - Last updated time. This is the Unix timestamp in milliseconds. -### Type `TxPoolVerbosity` - -Tx-pool verbose object - -#### Fields - -`TxPoolVerbosity` is a JSON object with the following fields. - -* `pending`: `{ [ key:` [`H256`](#type-h256) `]: ` [`TxVerbosity`](#type-txverbosity) `}` - Pending tx verbose info - -* `proposed`: `{ [ key:` [`H256`](#type-h256) `]: ` [`TxVerbosity`](#type-txverbosity) `}` - Proposed tx verbose info - - ### Type `TxStatus` Transaction status and the block hash if it is committed. @@ -4454,27 +4475,6 @@ Transaction status and the block hash if it is committed. * `block_hash`: [`H256`](#type-h256) `|` `null` - The block hash of the block which has committed this transaction in the canonical chain. -### Type `TxVerbosity` - -Transaction verbose info - -#### Fields - -`TxVerbosity` is a JSON object with the following fields. - -* `cycles`: [`Uint64`](#type-uint64) - Consumed cycles. - -* `size`: [`Uint64`](#type-uint64) - The transaction serialized size in block. - -* `fee`: [`Capacity`](#type-capacity) - The transaction fee. - -* `ancestors_size`: [`Uint64`](#type-uint64) - Size of in-tx-pool ancestor transactions - -* `ancestors_cycles`: [`Uint64`](#type-uint64) - Cycles of in-tx-pool ancestor transactions - -* `ancestors_count`: [`Uint64`](#type-uint64) - Number of in-tx-pool ancestor transactions - - ### Type `U256` The 256-bit unsigned integer type encoded as the 0x-prefixed hex string in JSON. diff --git a/util/jsonrpc-types/src/lib.rs b/util/jsonrpc-types/src/lib.rs index bbad4aa9dc..4f3f8c841e 100644 --- a/util/jsonrpc-types/src/lib.rs +++ b/util/jsonrpc-types/src/lib.rs @@ -41,8 +41,8 @@ pub use self::net::{ RemoteNodeProtocol, SyncState, }; pub use self::pool::{ - OutputsValidator, PoolTransactionEntry, PoolTransactionReject, RawTxPool, TxPoolIds, - TxPoolInfo, TxPoolVerbosity, TxVerbosity, + OutputsValidator, PoolTransactionEntry, PoolTransactionReject, RawTxPool, TxPoolEntries, + TxPoolEntry, TxPoolIds, TxPoolInfo, }; pub use self::proposal_short_id::ProposalShortId; pub use self::subscription::Topic; diff --git a/util/jsonrpc-types/src/pool.rs b/util/jsonrpc-types/src/pool.rs index 6764ac81c3..5ae79e6a9d 100644 --- a/util/jsonrpc-types/src/pool.rs +++ b/util/jsonrpc-types/src/pool.rs @@ -103,9 +103,9 @@ impl From for TxPoolIds { } } -/// Transaction verbose info +/// Transaction entry info #[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)] -pub struct TxVerbosity { +pub struct TxPoolEntry { /// Consumed cycles. pub cycles: Uint64, /// The transaction serialized size in block. @@ -120,9 +120,9 @@ pub struct TxVerbosity { pub ancestors_count: Uint64, } -impl From for TxVerbosity { +impl From for TxPoolEntry { fn from(info: TxEntryInfo) -> Self { - TxVerbosity { + TxPoolEntry { cycles: info.cycles.into(), size: info.size.into(), fee: info.fee.into(), @@ -133,20 +133,20 @@ impl From for TxVerbosity { } } -/// Tx-pool verbose object +/// Tx-pool entries object #[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Debug)] -pub struct TxPoolVerbosity { +pub struct TxPoolEntries { /// Pending tx verbose info - pub pending: HashMap, + pub pending: HashMap, /// Proposed tx verbose info - pub proposed: HashMap, + pub proposed: HashMap, } -impl From for TxPoolVerbosity { +impl From for TxPoolEntries { fn from(info: TxPoolEntryInfo) -> Self { let TxPoolEntryInfo { pending, proposed } = info; - TxPoolVerbosity { + TxPoolEntries { pending: pending .into_iter() .map(|(hash, entry)| (hash.unpack(), entry.into())) @@ -161,17 +161,17 @@ impl From for TxPoolVerbosity { /// All transactions in tx-pool. /// -/// `RawTxPool` is equivalent to [`TxPoolIds`][] `|` [`TxPoolVerbosity`][]. +/// `RawTxPool` is equivalent to [`TxPoolIds`][] `|` [`TxPoolEntries`][]. /// /// [`TxPoolIds`]: struct.TxPoolIds.html -/// [`TxPoolVerbosity`]: struct.TxPoolVerbosity.html +/// [`TxPoolEntries`]: struct.TxPoolEntries.html #[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Debug)] #[serde(untagged)] pub enum RawTxPool { /// verbose = false Ids(TxPoolIds), /// verbose = true - Verbose(TxPoolVerbosity), + Verbose(TxPoolEntries), } /// TX reject message