Skip to content

Commit

Permalink
refactor(rpc): change struct from "TxPoolVerbosity" to "TxPoolEntries…
Browse files Browse the repository at this point in the history
…", "TxVerbosity" to "TxPoolEntr
  • Loading branch information
chanhsu001 committed Sep 2, 2021
1 parent 89df60e commit b7527ad
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions devtools/doc/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
74 changes: 37 additions & 37 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions util/jsonrpc-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 13 additions & 13 deletions util/jsonrpc-types/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ impl From<CoreTxPoolIds> 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.
Expand All @@ -120,9 +120,9 @@ pub struct TxVerbosity {
pub ancestors_count: Uint64,
}

impl From<TxEntryInfo> for TxVerbosity {
impl From<TxEntryInfo> for TxPoolEntry {
fn from(info: TxEntryInfo) -> Self {
TxVerbosity {
TxPoolEntry {
cycles: info.cycles.into(),
size: info.size.into(),
fee: info.fee.into(),
Expand All @@ -133,20 +133,20 @@ impl From<TxEntryInfo> 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<H256, TxVerbosity>,
pub pending: HashMap<H256, TxPoolEntry>,
/// Proposed tx verbose info
pub proposed: HashMap<H256, TxVerbosity>,
pub proposed: HashMap<H256, TxPoolEntry>,
}

impl From<TxPoolEntryInfo> for TxPoolVerbosity {
impl From<TxPoolEntryInfo> 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()))
Expand All @@ -161,17 +161,17 @@ impl From<TxPoolEntryInfo> 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
Expand Down

0 comments on commit b7527ad

Please sign in to comment.