Skip to content

Commit

Permalink
fix rpc doc
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Oct 26, 2023
1 parent bdb9335 commit 66114bc
Showing 1 changed file with 0 additions and 133 deletions.
133 changes: 0 additions & 133 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 66114bc

Please sign in to comment.