diff --git a/rpc/README.md b/rpc/README.md index fe16348215..93a1253817 100644 --- a/rpc/README.md +++ b/rpc/README.md @@ -98,7 +98,6 @@ The crate `ckb-rpc`'s minimum supported rustc version is 1.71.1. * [Method `get_deployments_info`](#method-get_deployments_info) * [Module Subscription](#module-subscription) * [Method `subscribe`](#method-subscribe) - * [Method `unsubscribe`](#method-unsubscribe) * [RPC Errors](#rpc-errors) * [RPC Types](#rpc-types) * [Type `Alert`](#type-alert) @@ -4836,138 +4835,6 @@ socket.send(`{"id": 2, "jsonrpc": "2.0", "method": "unsubscribe", "params": ["0x * `topic`: `string` * result: `string` -Subscribes to a topic. - -###### Params - -* `topic` - Subscription topic (enum: new_tip_header | new_tip_block | new_transaction | proposed_transaction | rejected_transaction) - -###### Returns - -This RPC returns the subscription ID as the result. CKB node will push messages in the subscribed topics to the current RPC connection. The subscript ID is also attached as `params.subscription` in the push messages. - -Example push message: - - -``` -{ - "jsonrpc": "2.0", - "method": "subscribe", - "params": { - "result": { ... }, - "subscription": "0x2a" - } -} -``` - - -###### Topics - -###### `new_tip_header` - -Whenever there’s a block that is appended to the canonical chain, the CKB node will publish the block header to subscribers. - -The type of the `params.result` in the push message is [`HeaderView`](#type-headerview). - -###### `new_tip_block` - -Whenever there’s a block that is appended to the canonical chain, the CKB node will publish the whole block to subscribers. - -The type of the `params.result` in the push message is [`BlockView`](#type-blockview). - -###### `new_transaction` - -Subscribers will get notified when a new transaction is submitted to the pool. - -The type of the `params.result` in the push message is [`PoolTransactionEntry`](#type-pooltransactionentry). - -###### `proposed_transaction` - -Subscribers will get notified when an in-pool transaction is proposed by chain. - -The type of the `params.result` in the push message is [`PoolTransactionEntry`](#type-pooltransactionentry). - -###### `rejected_transaction` - -Subscribers will get notified when a pending transaction is rejected by tx-pool. - -The type of the `params.result` in the push message is an array contain: - -The type of the `params.result` in the push message is a two-elements array, where - -* the first item type is [`PoolTransactionEntry`](#type-pooltransactionentry), and - -* the second item type is [`PoolTransactionReject`](#type-pooltransactionreject). - -###### Examples - -Request - - -``` -{ - "id": 42, - "jsonrpc": "2.0", - "method": "subscribe", - "params": [ - "new_tip_header" - ] -} -``` - - -Response - - -``` -{ - "id": 42, - "jsonrpc": "2.0", - "result": "0x2a" -} -``` - - -#### Method `unsubscribe` -* `unsubscribe(id)` - * `id`: `string` -* result: `boolean` - -Unsubscribes from a subscribed topic. - -###### Params - -* `id` - Subscription ID - -###### Examples - -Request - - -``` -{ - "id": 42, - "jsonrpc": "2.0", - "method": "unsubscribe", - "params": [ - "0x2a" - ] -} -``` - - -Response - - -``` -{ - "id": 42, - "jsonrpc": "2.0", - "result": true -} -``` - - ## RPC Errors