Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rich-indexer which is another built-in indexer based on relational database #4224

Merged
merged 129 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
3c0247c
split indexer-sync from indexer-service.
EthanYuan Oct 26, 2023
e581c74
split indexer-sync from indexer-service.
EthanYuan Oct 26, 2023
de3251c
add pool method to IndexerSync.
EthanYuan Oct 26, 2023
0f9e8a3
refactoring: IndexerSyncService
EthanYuan Oct 27, 2023
96b9b94
refactoring: extract PoolService.
EthanYuan Oct 30, 2023
346eda2
fix clippy error.
EthanYuan Oct 31, 2023
39e6ec1
add crate indexer-r.
EthanYuan Nov 2, 2023
f0bafeb
add indexer-r config.
EthanYuan Nov 4, 2023
c6087a2
add indexer-r rpc and init indexer-r service.
EthanYuan Nov 4, 2023
9c9437a
add indexer-r store layer.
EthanYuan Nov 5, 2023
f90c9b6
refactoring: move custom_filter.rs.
EthanYuan Nov 5, 2023
b0421d1
add indexer module in indexer-r.
EthanYuan Nov 5, 2023
65c02a6
add indexer handle and async_handle.
EthanYuan Nov 6, 2023
565219f
add create_sqlite_table sql and tests.
EthanYuan Nov 7, 2023
ee3c476
add test test_query_tip.
EthanYuan Nov 7, 2023
48194a3
impl insert block table.
EthanYuan Nov 7, 2023
bb705e8
re-design tables.
EthanYuan Nov 8, 2023
4149431
impl bulk_insert_script_table.
EthanYuan Nov 8, 2023
968114a
impl bulk_insert_output_table.
EthanYuan Nov 8, 2023
fc4b842
impl bulk_insert_input_table.
EthanYuan Nov 9, 2023
82a9d43
impl bulk_insert_transaction_table
EthanYuan Nov 9, 2023
2da15a1
refactoring.
EthanYuan Nov 9, 2023
00d6883
impl bulk_insert_block_association_proposal_table
EthanYuan Nov 9, 2023
0d954a0
impl insert_uncle_block
EthanYuan Nov 9, 2023
8af965c
impl
EthanYuan Nov 9, 2023
3c33d69
impl buil_insert_output_association_script.
EthanYuan Nov 9, 2023
8620e9f
impl rollback.
EthanYuan Nov 9, 2023
84c4317
impl rollback associations.
EthanYuan Nov 12, 2023
b0912b1
fix: indexer-r store path.
EthanYuan Nov 14, 2023
a12c189
add sub command to enable indexer-r.
EthanYuan Nov 14, 2023
a28f3e1
add get_identity for trait IndexerSync.
EthanYuan Nov 15, 2023
71d570e
fix: SQL_CREATE_SQLITE path issue.
EthanYuan Nov 15, 2023
b702001
add postgres init.
EthanYuan Nov 16, 2023
911d0de
enable indexer-r block filter.
EthanYuan Nov 18, 2023
09e4ebf
enable indexer-r output cell filter.
EthanYuan Nov 19, 2023
26faeea
enable indexer-r input cell filter.
EthanYuan Nov 19, 2023
207f961
check filter enable.
EthanYuan Nov 19, 2023
68c626f
add append_block_with_filter_mode.
EthanYuan Nov 20, 2023
8ce479d
update table schema: remove output_association_script
EthanYuan Nov 20, 2023
5e60062
improve query script_exists.
EthanYuan Nov 21, 2023
4fe3056
Setting init tip number allows skipping the synchronization of previo…
EthanYuan Nov 21, 2023
ac538c6
Improve code based on review feedback.
EthanYuan Nov 22, 2023
9f1c8b9
add id in table input.
EthanYuan Dec 1, 2023
9c37beb
rename append_block_with_filter_mode to append_block_header.
EthanYuan Dec 3, 2023
cce154a
use CREATE INDEX instead of UNIQUE.
EthanYuan Dec 3, 2023
0bd98a1
improve: query_tip.
EthanYuan Dec 3, 2023
d3a4de1
Optimize rich-indexer synchronization: Implement bulk insertion of bl…
EthanYuan Dec 4, 2023
658baf5
* rm try_loop_sync_fast
EthanYuan Dec 5, 2023
31dbd34
remove script_exists when insert script.
EthanYuan Dec 5, 2023
7d591e6
bug fix when bulk insert.
EthanYuan Dec 6, 2023
bfc605d
use CONCURRENTLY to CREATE INDEX.
EthanYuan Dec 6, 2023
9ba6ef4
bug fix: query_outputs_by_tx_hashes, type script may none.
EthanYuan Dec 11, 2023
abbd0cc
update database schema.
EthanYuan Dec 11, 2023
2a590b1
re-impl append_block.
EthanYuan Dec 12, 2023
4820307
re-impl insert tx table.
EthanYuan Dec 12, 2023
d9abffe
impl insert and rollback.
EthanYuan Dec 13, 2023
a3a0e8b
use create index sql when create table.
EthanYuan Dec 13, 2023
8460524
improve: query output when insert input.
EthanYuan Dec 14, 2023
74d1ac7
update table schema: script unique add `hash_type`.
EthanYuan Dec 15, 2023
7862f48
improve sql: script_exists_in_output.
EthanYuan Dec 15, 2023
98d750d
modification for rebase.
EthanYuan Dec 17, 2023
9f40736
Renamed package to ckb-rich-indexer
EthanYuan Dec 17, 2023
35f1f4e
Change all indexer-r to ckb-rich-indexer.
EthanYuan Dec 17, 2023
68ea81f
fix:
EthanYuan Dec 18, 2023
ddf9630
update tables' fileds type:
EthanYuan Dec 18, 2023
3283fd9
wip
quake Dec 19, 2023
bcd2cc6
refactoring: extract bulk_insert_table func.
EthanYuan Dec 20, 2023
14ea3b8
refactoring: insert for all tables
EthanYuan Dec 21, 2023
741b275
remove seq-macro dep.
EthanYuan Dec 25, 2023
6a4571c
extend IndexerSearchKey: add `data` and `data_search_mode`.
EthanYuan Dec 26, 2023
3054e0b
impl the main body of the method query_cells.
EthanYuan Dec 26, 2023
f82bd3c
impl the order/limit/after in query_cells.
EthanYuan Dec 28, 2023
b699d68
remove unused paging code.
EthanYuan Dec 28, 2023
70086ee
finish rich indexer query_cells.
EthanYuan Dec 28, 2023
0cabc3e
fix `script_len_range` filter query.
EthanYuan Dec 29, 2023
68c9a79
impl rpc `get_transactions`.
EthanYuan Jan 2, 2024
3879dfc
renamed filed name `output_data` in `IndexerSearchKeyFilter`.
EthanYuan Jan 2, 2024
8f45276
impl rpc get_cells_capacity
EthanYuan Jan 2, 2024
a097815
add unit tests `with_custom_block_filter` and `with_custom_cell_filter`.
EthanYuan Jan 2, 2024
f6ea74f
fix a bug: If the input cannot find the corresponding output through …
EthanYuan Jan 2, 2024
8f1d1b8
update for rebase.
EthanYuan Jan 2, 2024
bdfe40c
improve sql of `get_cells_capacity`.
EthanYuan Jan 3, 2024
1bbdb99
rename the rpc methods of rich-indexer, keep the same as indexer.
EthanYuan Jan 3, 2024
d7bab86
add stress test scripts.
EthanYuan Jan 3, 2024
917874a
fix postgres compatibility issue.
EthanYuan Jan 3, 2024
497a632
fix a potential panic, `indexer.tip` may fail.
EthanYuan Jan 4, 2024
a7f3601
fix sql for postgres: sum ( bigint ) → numeric
EthanYuan Jan 4, 2024
31bfb3b
fix sql `like` escape issue.
EthanYuan Jan 5, 2024
81cf614
fix partial mode stress script.
EthanYuan Jan 5, 2024
6b1a5e1
add prefix mode test script.
EthanYuan Jan 8, 2024
0a3d6af
improve sql query: get_cells and get_cells_capacity.
EthanYuan Jan 8, 2024
5ba76ac
fix get_cells_capacity.
EthanYuan Jan 9, 2024
03cad0d
re impl `get_transactions` ungroup
EthanYuan Jan 10, 2024
a3f546e
re impl `get_transactions`
EthanYuan Jan 10, 2024
c53be57
improve sql for get_transactions.
EthanYuan Jan 15, 2024
fe608c4
improve prefix: use >= and <, instead of LIKE.
EthanYuan Jan 15, 2024
0920e9b
refactoring.
EthanYuan Jan 16, 2024
8a1d53c
use position/instr instead of LIKE.
EthanYuan Jan 16, 2024
449098d
rebase.
EthanYuan Jan 16, 2024
60570d3
refactoring: remove unused db config.
EthanYuan Jan 18, 2024
4443b4f
get_cells and get_cells_capacity support tx pool with dead cells.
EthanYuan Jan 24, 2024
8f1e674
rebase
EthanYuan Jan 28, 2024
060ac6a
specify more column family for secondary db:
EthanYuan Jan 28, 2024
ef0836d
optimize table:
EthanYuan Jan 29, 2024
6afeec4
remove unused lines.
EthanYuan Jan 29, 2024
57f8884
impl reset-data --rich-indexer (Delete only `data/indexer/sqlite`).
EthanYuan Jan 29, 2024
c75f85a
add readme for rich-indexer.
EthanYuan Jan 31, 2024
b13764f
fix make clippy warnings.
EthanYuan Jan 31, 2024
4b3522a
update rpc doc.
EthanYuan Jan 31, 2024
f084e0f
fix ci quick-test.
EthanYuan Jan 31, 2024
f45e499
fix ci quick checks
EthanYuan Feb 1, 2024
4ba465a
fix trailing whitespace.
EthanYuan Feb 1, 2024
3d6e9a7
check rpc doc.
EthanYuan Feb 1, 2024
0c5bb19
fix ci: update the order of workspace members.
EthanYuan Feb 1, 2024
d3f1de0
fix ci: security-audit, yanked version wasm-bindgen 0.2.88
EthanYuan Feb 4, 2024
24273bd
re-generate rich-indexer rpc doc.
EthanYuan Feb 6, 2024
134cfb9
fix ci cli-bats-test
EthanYuan Feb 8, 2024
eadea92
rebase.
EthanYuan Feb 9, 2024
e8b34c7
fix ci: error compiling sqlx with compiler under aarch64.
EthanYuan Feb 16, 2024
5d1c411
add RUSTSEC-2022-0090 and remove RUSTSEC-2021-0145 from the deny igno…
EthanYuan Feb 18, 2024
eb98713
rebase
EthanYuan Feb 19, 2024
f291c9a
fix indexer pool: when block filter no match should call `transaction…
EthanYuan Feb 23, 2024
3742bd0
limit index tx pool: will only be activated when the index tip is les…
EthanYuan Feb 23, 2024
0c296f9
update rpc doc.
EthanYuan Feb 25, 2024
ed3f5d4
fix readme typo.
EthanYuan Feb 26, 2024
9b9c3fe
Change the position of the log 'PostgreSQL is connected'.
EthanYuan Mar 13, 2024
a9f7609
fix: rich-indexer rpc accept u64::MAX may return empty, so convert u6…
EthanYuan Mar 13, 2024
e05e703
bump rich-indexer version.
EthanYuan Mar 14, 2024
5dd4901
fix clippy warning.
EthanYuan Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
552 changes: 521 additions & 31 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ members = [
"db-migration",
"util/network-alert",
"store",
"util/indexer-sync",
"util/indexer",
"util/rich-indexer",
"util/chain-iter",
"util/dao",
"util/test-chain-utils",
Expand Down
4 changes: 4 additions & 0 deletions ckb-bin/src/subcommand/reset_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ pub fn reset_data(args: ResetDataArgs) -> Result<(), ExitCode> {
target_dirs.push(args.indexer_path);
}

if args.rich_indexer {
target_dirs.push(args.rich_indexer_path);
}

if args.network {
target_dirs.push(args.network_dir);
}
Expand Down
2 changes: 2 additions & 0 deletions ckb-bin/src/subcommand/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub fn run(args: RunArgs, version: Version, async_handle: Handle) -> Result<(),
let block_assembler_config = launcher.sanitize_block_assembler_config()?;
let miner_enable = block_assembler_config.is_some();

launcher.check_indexer_config()?;

let (shared, mut pack) = launcher.build_shared(block_assembler_config)?;

// spawn freezer background process
Expand Down
6 changes: 5 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ yanked = "deny"
notice = "deny"
ignore = [
# waiting https://github.com/bheisler/criterion.rs/pull/628 bump release
"RUSTSEC-2021-0145"
"RUSTSEC-2021-0145",
# The CVE can be kept under control for its triggering.
# See https://github.com/launchbadge/sqlx/pull/2455#issuecomment-1507657825 for more information.
# Meanwhile, awaiting SQLx's new version (> 0.7.3) for full support of any DB driver.
"RUSTSEC-2022-0090"
]

[licenses]
Expand Down
1 change: 1 addition & 0 deletions devtools/doc/rpc-gen/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) fn all_rpc_docs() -> Vec<(String, Value)> {
stats_rpc_doc,
integration_test_rpc_doc,
indexer_rpc_doc,
rich_indexer_rpc_doc,
experiment_rpc_doc,
)
.into()
Expand Down
16 changes: 14 additions & 2 deletions resource/ckb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ listen_address = "127.0.0.1:8114" # {{
# Default is 10MiB = 10 * 1024 * 1024
max_request_body_size = 10485760

# List of API modules: ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment", "Debug", "Indexer"]
# List of API modules: ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment", "Debug", "Indexer", "RichIndexer"]
modules = ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment"] # {{
# dev => modules = ["Net", "Pool", "Miner", "Chain", "Stats", "Subscription", "Experiment", "Debug"]
# integration => modules = ["Net", "Pool", "Miner", "Chain", "Experiment", "Stats", "IntegrationTest"]
Expand Down Expand Up @@ -196,7 +196,8 @@ block_uncles_cache_size = 30
# # Or you may want use more flexible scripts, block template as arg.
# notify_scripts = ["{cmd} {blocktemplate}"]
#
# # CKB built-in indexer settings. Existing indexes can be cleaned up using the `ckb reset-data --indexer` subcommand.
# # CKB built-in indexer/rich-indexer settings.
# # Utilize the `ckb reset-data --indexer` and `ckb reset-data --rich-indexer` subcommands to efficiently clean existing indexes.
# [indexer_v2]
# # Indexing the pending txs in the ckb tx-pool
# index_tx_pool = false
Expand All @@ -206,3 +207,14 @@ block_uncles_cache_size = 30
# cell_filter = "let script = output.type;script!=() && script.code_hash == \"0x00000000000000000000000000000000000000000000000000545950455f4944\""
# # The initial tip can be set higher than the current indexer tip as the starting height for indexing.
# init_tip_hash = "0x8fbd0ec887159d2814cee475911600e3589849670f5ee1ed9798b38fdeef4e44"
#
# # CKB rich-indexer has its unique configuration.
# [indexer_v2.rich_indexer]
# # By default, it uses an embedded SQLite database.
# # Alternatively, you can set up a PostgreSQL database service and provide the connection parameters.
# db_type = "postgres"
# db_name = "ckb-rich-indexer"
# db_host = "127.0.0.1"
# db_port = 5432
# db_user = "postgres"
# db_password = "123456"
2 changes: 2 additions & 0 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ ckb-tx-pool = { path = "../tx-pool", version = "= 0.115.0-pre" }
ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.115.0-pre" }
ckb-pow = { path = "../pow", version = "= 0.115.0-pre" }
ckb-indexer = { path = "../util/indexer", version = "= 0.115.0-pre" }
ckb-indexer-sync = { path = "../util/indexer-sync", version = "= 0.115.0-pre" }
ckb-rich-indexer = { path = "../util/rich-indexer", version = "= 0.115.0-pre" }
ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.115.0-pre" }
itertools.workspace = true
tokio = "1"
Expand Down
163 changes: 163 additions & 0 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ The crate `ckb-rpc`'s minimum supported rustc version is 1.71.1.
* [Method `get_raw_tx_pool`](#pool-get_raw_tx_pool)
* [Method `get_pool_tx_detail_info`](#pool-get_pool_tx_detail_info)
* [Method `tx_pool_ready`](#pool-tx_pool_ready)
* [Module Rich_indexer](#module-rich_indexer) [👉 OpenRPC spec](http://playground.open-rpc.org/?uiSchema[appBar][ui:title]=CKB-Rich_indexer&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:examplesDropdown]=false&uiSchema[appBar][ui:logoUrl]=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/ckb-logo.jpg&schemaUrl=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/json/rich_indexer_rpc_doc.json)

* [Method `get_indexer_tip`](#rich_indexer-get_indexer_tip)
* [Method `get_cells`](#rich_indexer-get_cells)
* [Method `get_transactions`](#rich_indexer-get_transactions)
* [Method `get_cells_capacity`](#rich_indexer-get_cells_capacity)
* [Module Stats](#module-stats) [👉 OpenRPC spec](http://playground.open-rpc.org/?uiSchema[appBar][ui:title]=CKB-Stats&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:examplesDropdown]=false&uiSchema[appBar][ui:logoUrl]=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/ckb-logo.jpg&schemaUrl=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/json/stats_rpc_doc.json)

* [Method `get_blockchain_info`](#stats-get_blockchain_info)
Expand Down Expand Up @@ -4649,6 +4655,163 @@ Response
}
```

### Module `Rich_indexer`
- [👉 OpenRPC spec](http://playground.open-rpc.org/?uiSchema[appBar][ui:title]=CKB-Rich_indexer&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:examplesDropdown]=false&uiSchema[appBar][ui:logoUrl]=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/ckb-logo.jpg&schemaUrl=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/json/rich_indexer_rpc_doc.json)


RPC Module Rich Indexer.

<a id="rich_indexer-get_indexer_tip"></a>
#### Method `get_indexer_tip`
* `get_indexer_tip()`

* result: [`IndexerTip`](#type-indexertip) `|` `null`

Returns the indexed tip.

###### Returns
* block_hash - indexed tip block hash
* block_number - indexed tip block number

###### Examples

Same as CKB Indexer.

<a id="rich_indexer-get_cells"></a>
#### Method `get_cells`
* `get_cells(search_key, order, limit, after)`
* `search_key`: [`IndexerSearchKey`](#type-indexersearchkey)
* `order`: [`IndexerOrder`](#type-indexerorder)
* `limit`: [`Uint32`](#type-uint32)
* `after`: [`JsonBytes`](#type-jsonbytes) `|` `null`
* result: [`IndexerPagination_for_IndexerCell`](#type-indexerpagination_for_indexercell)

Returns the live cells collection by the lock or type script.

The difference from the original CKB Indexer is that the `script_search_mode` parameter accepts the `partial` enumeration value. This implies that a partial search can be conducted on the `args` of the `script`.

###### Params

* search_key:
- script - Script, supports prefix search
- script_type - enum, lock | type
- script_search_mode - enum, prefix | exact | partial
- filter - filter cells by following conditions, all conditions are optional
- script: if search script type is lock, filter cells by type script prefix, and vice versa
- script_len_range: [u64; 2], filter cells by script len range, [inclusive, exclusive]
- output_data: filter cells by output data
- output_data_filter_mode: enum, prefix | exact | partial
- output_data_len_range: [u64; 2], filter cells by output data len range, [inclusive, exclusive]
- output_capacity_range: [u64; 2], filter cells by output capacity range, [inclusive, exclusive]
- block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]
- with_data - bool, optional default is `true`, if with_data is set to false, the field of returning cell.output_data is null in the result
* order: enum, asc | desc
* limit: result size limit
* after: pagination parameter, optional

###### Returns

If the number of objects is less than the requested `limit`, it indicates that these are the last page of get_cells.

* objects:
- output: the fields of an output cell
- output_data: the cell data
- out_point: reference to a cell via transaction hash and output index
- block_number: the number of the transaction committed in the block
- tx_index: the position index of the transaction committed in the block
* last_cursor: pagination parameter

###### Examples

Same as CKB Indexer.

<a id="rich_indexer-get_transactions"></a>
#### Method `get_transactions`
* `get_transactions(search_key, order, limit, after)`
* `search_key`: [`IndexerSearchKey`](#type-indexersearchkey)
* `order`: [`IndexerOrder`](#type-indexerorder)
* `limit`: [`Uint32`](#type-uint32)
* `after`: [`JsonBytes`](#type-jsonbytes) `|` `null`
* result: [`IndexerPagination_for_IndexerTx`](#type-indexerpagination_for_indexertx)

Returns the transactions collection by the lock or type script.

The difference from the original CKB Indexer is that both the `script_search_mode` and `output_data_filter_mode` in `filter` can accept the `partial` enumeration value. This implies that a partial search can be conducted on both the `args` of the `script` and the cell `output_data`.

* search_key:
- script - Script, supports prefix search when group_by_transaction is false
- script_type - enum, lock | type
- script_search_mode - enum, prefix | exact | partial
- filter - filter cells by following conditions, all conditions are optional
- script: if search script type is lock, filter cells by type script, and vice versa
- script_len_range: [u64; 2], filter cells by script len range, [inclusive, exclusive]
- output_data: filter cells by output data
- output_data_filter_mode: enum, prefix | exact | partial
- output_data_len_range: [u64; 2], filter cells by output data len range, [inclusive, exclusive]
- output_capacity_range: [u64; 2], filter cells by output capacity range, [inclusive, exclusive]
- block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]
- group_by_transaction - bool, optional default is `false`, if group_by_transaction is set to true, the returning objects will be grouped by the tx hash
* order: enum, asc | desc
* limit: result size limit
* after: pagination parameter, optional

###### Returns

If the number of objects is less than the requested `limit`, it indicates that these are the last page of get_transactions.

* objects - enum, ungrouped TxWithCell | grouped TxWithCells
- TxWithCell:
- tx_hash: transaction hash,
- block_number: the number of the transaction committed in the block
- tx_index: the position index of the transaction committed in the block
- io_type: enum, input | output
- io_index: the position index of the cell in the transaction inputs or outputs
- TxWithCells:
- tx_hash: transaction hash,
- block_number: the number of the transaction committed in the block
- tx_index: the position index of the transaction committed in the block
- cells: Array [[io_type, io_index]]
* last_cursor - pagination parameter

###### Examples

Same as CKB Indexer.

<a id="rich_indexer-get_cells_capacity"></a>
#### Method `get_cells_capacity`
* `get_cells_capacity(search_key)`
* `search_key`: [`IndexerSearchKey`](#type-indexersearchkey)
* result: [`IndexerCellsCapacity`](#type-indexercellscapacity) `|` `null`

Returns the live cells capacity by the lock or type script.

The difference from the original CKB Indexer is that the `script_search_mode` parameter accepts the `partial` enumeration value. This implies that a partial search can be conducted on the `args` of the `script`.

###### Parameters

* search_key:
- script - Script
- script_type - enum, lock | type
- script_search_mode - enum, prefix | exact | partial
- filter - filter cells by following conditions, all conditions are optional
- script: if search script type is lock, filter cells by type script prefix, and vice versa
- script_len_range: [u64; 2], filter cells by script len range, [inclusive, exclusive]
- output_data: filter cells by output data
- output_data_filter_mode: enum, prefix | exact | partial
- output_data_len_range: [u64; 2], filter cells by output data len range, [inclusive, exclusive]
- output_capacity_range: [u64; 2], filter cells by output capacity range, [inclusive, exclusive]
- block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]

###### Returns

* capacity - total capacity
* block_hash - indexed tip block hash
* block_number - indexed tip block number

###### Examples

Same as CKB Indexer.

### Module `Stats`
- [👉 OpenRPC spec](http://playground.open-rpc.org/?uiSchema[appBar][ui:title]=CKB-Stats&uiSchema[appBar][ui:splitView]=false&uiSchema[appBar][ui:examplesDropdown]=false&uiSchema[appBar][ui:logoUrl]=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/ckb-logo.jpg&schemaUrl=https://raw.githubusercontent.com/nervosnetwork/ckb-rpc-resources/develop/json/stats_rpc_doc.json)

Expand Down
3 changes: 3 additions & 0 deletions rpc/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ mod indexer;
mod miner;
mod net;
pub(crate) mod pool;
mod rich_indexer;
mod stats;
mod subscription;
mod test;
Expand All @@ -130,6 +131,7 @@ pub(crate) use self::indexer::IndexerRpcImpl;
pub(crate) use self::miner::MinerRpcImpl;
pub(crate) use self::net::NetRpcImpl;
pub(crate) use self::pool::PoolRpcImpl;
pub(crate) use self::rich_indexer::RichIndexerRpcImpl;
pub(crate) use self::stats::StatsRpcImpl;
pub(crate) use self::subscription::SubscriptionRpcImpl;
pub(crate) use self::test::IntegrationTestRpcImpl;
Expand All @@ -142,6 +144,7 @@ pub use self::indexer::{add_indexer_rpc_methods, indexer_rpc_doc, IndexerRpc};
pub use self::miner::{add_miner_rpc_methods, miner_rpc_doc, MinerRpc};
pub use self::net::{add_net_rpc_methods, net_rpc_doc, NetRpc};
pub use self::pool::{add_pool_rpc_methods, pool_rpc_doc, PoolRpc};
pub use self::rich_indexer::{add_rich_indexer_rpc_methods, rich_indexer_rpc_doc, RichIndexerRpc};
pub use self::stats::{add_stats_rpc_methods, stats_rpc_doc, StatsRpc};
pub use self::subscription::{add_subscription_rpc_methods, subscription_rpc_doc, SubscriptionRpc};
pub use self::test::{
Expand Down
Loading
Loading