Skip to content

Commit

Permalink
Merge pull request #4303 from EthanYuan/indexer-support-data-search
Browse files Browse the repository at this point in the history
feat(indexer): support cell data filter
  • Loading branch information
zhangsoledad authored Jan 25, 2024
2 parents 2d03596 + 09accaf commit 48785ed
Show file tree
Hide file tree
Showing 7 changed files with 424 additions and 39 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 33 additions & 12 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ The crate `ckb-rpc`'s minimum supported rustc version is 1.71.1.
* [Type `IndexerCellsCapacity`](#type-indexercellscapacity)
* [Type `IndexerOrder`](#type-indexerorder)
* [Type `IndexerRange`](#type-indexerrange)
* [Type `IndexerScriptSearchMode`](#type-indexerscriptsearchmode)
* [Type `IndexerScriptType`](#type-indexerscripttype)
* [Type `IndexerSearchKey`](#type-indexersearchkey)
* [Type `IndexerSearchKeyFilter`](#type-indexersearchkeyfilter)
* [Type `IndexerSearchMode`](#type-indexersearchmode)
* [Type `IndexerTip`](#type-indexertip)
* [Type `IndexerTx`](#type-indexertx)
* [Type `JsonBytes`](#type-jsonbytes)
Expand Down Expand Up @@ -2164,11 +2164,17 @@ Returns the live cells collection by the lock or type script.

* script_type - enum, lock | type

* script_search_mode - enum, prefix | exact

* 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]
Expand Down Expand Up @@ -2549,6 +2555,8 @@ Returns the transactions collection by the lock or type script.

* script_type - enum, lock | type

* script_search_mode - enum, prefix | exact

* 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

Expand Down Expand Up @@ -2992,9 +3000,17 @@ Returns the live cells capacity by the lock or type script.

* script_type - enum, lock | type

* script_search_mode - enum, prefix | exact

* 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]
Expand Down Expand Up @@ -6183,16 +6199,6 @@ A array represent (half-open) range bounded inclusively below and exclusively ab



### Type `IndexerScriptSearchMode`

IndexerScriptSearchMode represent script search mode, default is prefix search

`IndexerScriptSearchMode` is equivalent to `"prefix" | "exact"`.

* Mode `prefix` search script with prefix
* Mode `exact` search script with exact match


### Type `IndexerScriptType`

ScriptType `Lock` | `Type`
Expand All @@ -6215,7 +6221,7 @@ SearchKey represent indexer support params

* `script_type`: [`IndexerScriptType`](#type-indexerscripttype) - Script Type

* `script_search_mode`: [`IndexerScriptSearchMode`](#type-indexerscriptsearchmode) `|` `null` - Script search mode, optional default is `prefix`, means search script with prefix
* `script_search_mode`: [`IndexerSearchMode`](#type-indexersearchmode) `|` `null` - Script search mode, optional default is `prefix`, means search script with prefix

* `filter`: [`IndexerSearchKeyFilter`](#type-indexersearchkeyfilter) `|` `null` - filter cells by following conditions, all conditions are optional

Expand All @@ -6236,13 +6242,28 @@ IndexerSearchKeyFilter represent indexer params `filter`

* `script_len_range`: [`IndexerRange`](#type-indexerrange) `|` `null` - filter cells by script len range

* `output_data`: [`JsonBytes`](#type-jsonbytes) `|` `null` - filter cells by output data

* `output_data_filter_mode`: [`IndexerSearchMode`](#type-indexersearchmode) `|` `null` - output data filter mode, optional default is `prefix`

* `output_data_len_range`: [`IndexerRange`](#type-indexerrange) `|` `null` - filter cells by output data len range

* `output_capacity_range`: [`IndexerRange`](#type-indexerrange) `|` `null` - filter cells by output capacity range

* `block_range`: [`IndexerRange`](#type-indexerrange) `|` `null` - filter cells by block number range


### Type `IndexerSearchMode`

IndexerSearchMode represent search mode, default is prefix search

`IndexerSearchMode` is equivalent to `"prefix" | "exact" | "partial"`.

* Mode `prefix` search with prefix
* Mode `exact` search with exact match
* Mode `partial` search with partial match


### Type `IndexerTip`

Indexer tip information
Expand Down
8 changes: 8 additions & 0 deletions rpc/src/module/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ pub trait IndexerRpc {
/// * search_key:
/// - script - Script, supports prefix search
/// - script_type - enum, lock | type
/// - script_search_mode - enum, prefix | exact
/// - 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]
Expand Down Expand Up @@ -404,6 +407,7 @@ pub trait IndexerRpc {
/// * search_key:
/// - script - Script, supports prefix search when group_by_transaction is false
/// - script_type - enum, lock | type
/// - script_search_mode - enum, prefix | exact
/// - 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
/// - block_range: [u64; 2], filter cells by block number range, [inclusive, exclusive]
Expand Down Expand Up @@ -821,8 +825,12 @@ pub trait IndexerRpc {
/// * search_key:
/// - script - Script
/// - script_type - enum, lock | type
/// - script_search_mode - enum, prefix | exact
/// - 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]
Expand Down
2 changes: 2 additions & 0 deletions util/indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ ckb-async-runtime = { path = "../runtime", version = "= 0.114.0-pre" }
rhai = { version = "1.10.0", features = ["no_function", "no_float", "no_module", "sync"]}
serde_json = "1.0"
numext-fixed-uint = "0.1"
memchr = "2.7"

[dev-dependencies]
tempfile.workspace = true
rand = "0.8"
faster-hex = "0.6"
Loading

0 comments on commit 48785ed

Please sign in to comment.