Skip to content

Commit

Permalink
feat(rpc): add total_tx_cycles and total_tx_size in tx_pool_info
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed May 27, 2019
1 parent 711bd62 commit 5db06fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/ckb-sdk-rpc/__tests__/formatters/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,17 @@
"orphan": "33",
"pending": "34",
"proposed": "22",
"last_txs_updated_at": "1555507787683"
"last_txs_updated_at": "1555507787683",
"total_tx_cycles": "12",
"total_tx_size": "156"
},
"target": {
"orphan": "33",
"pending": "34",
"proposed": "22",
"lastTxsUpdatedAt": "1555507787683"
"lastTxsUpdatedAt": "1555507787683",
"totalTxCycles": "12",
"totalTxSize": "156"
}
}],
"toPeers": [{
Expand Down
9 changes: 8 additions & 1 deletion packages/ckb-sdk-rpc/src/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,16 @@ const formatter = {
},
toTxPoolInfo: (info: CKB_RPC.TxPoolInfo): CKBComponents.TxPoolInfo => {
if (!info) return info
const { last_txs_updated_at: lastTxsUpdatedAt, ...rest } = info
const {
last_txs_updated_at: lastTxsUpdatedAt,
total_tx_cycles: totalTxCycles,
total_tx_size: totalTxSize,
...rest
} = info
return {
lastTxsUpdatedAt,
totalTxCycles,
totalTxSize,
...rest,
}
},
Expand Down
4 changes: 4 additions & 0 deletions packages/ckb-sdk-rpc/types/CKB_RPC/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ declare module CKB_RPC {
export type BlockNumber = CKBComponents.BlockNumber
export type EpochInHeader = string
export type Difficulty = CKBComponents.Difficulty
export type Cycles = CKBComponents.Cycles
export type Size = CKBComponents.Size

export enum TransactionStatus {
Pending = 'pending',
Expand Down Expand Up @@ -138,6 +140,8 @@ declare module CKB_RPC {
pending: Count
proposed: Count
last_txs_updated_at: Timestamp
total_tx_cycles: Cycles
total_tx_size: Size
}

export interface Epoch {
Expand Down
3 changes: 3 additions & 0 deletions packages/ckb-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare namespace CKBComponents {
export type Timestamp = string
export type Nonce = string
export type Cycles = string
export type Size = string
/**
* @typedef Bytes, keep consistent with CKB
* @description Bytes will be serialized to string
Expand Down Expand Up @@ -243,6 +244,8 @@ declare namespace CKBComponents {
pending: Count
proposed: Count
lastTxsUpdatedAt: Timestamp
totalTxCycles: Cycles
totalTxSize: Size
}

export enum CapacityUnit {
Expand Down

0 comments on commit 5db06fa

Please sign in to comment.