From ecae3066967d984d07692c1b847fd797feff59e4 Mon Sep 17 00:00:00 2001 From: EthanYuan Date: Tue, 16 Jan 2024 19:44:20 +0800 Subject: [PATCH] update rpc readme. --- rpc/README.md | 45 +++++++++++++++++++++++++++---------- rpc/src/module/indexer.rs | 8 +++++++ util/indexer/src/service.rs | 22 +++++++----------- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/rpc/README.md b/rpc/README.md index 0424230bca..315b5eeb40 100644 --- a/rpc/README.md +++ b/rpc/README.md @@ -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) @@ -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] @@ -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 @@ -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] @@ -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` @@ -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 @@ -6236,6 +6242,10 @@ 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 @@ -6243,6 +6253,17 @@ IndexerSearchKeyFilter represent indexer params `filter` * `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 diff --git a/rpc/src/module/indexer.rs b/rpc/src/module/indexer.rs index 0ade79bf67..1fd8dca836 100644 --- a/rpc/src/module/indexer.rs +++ b/rpc/src/module/indexer.rs @@ -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] @@ -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] @@ -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] diff --git a/util/indexer/src/service.rs b/util/indexer/src/service.rs index af35e7c5ba..26966e0072 100644 --- a/util/indexer/src/service.rs +++ b/util/indexer/src/service.rs @@ -340,7 +340,7 @@ impl IndexerHandle { .unwrap_or(false) { return Err(Error::invalid_params( - "the CKB indexer doesn't support script partial search mode.", + "doesn't support search_key.script_search_mode partial search mode", )); } @@ -527,18 +527,7 @@ impl IndexerHandle { .unwrap_or(false) { return Err(Error::invalid_params( - "the CKB indexer doesn't support script partial search mode.", - )); - } - - if search_key - .filter - .as_ref() - .map(|filter| filter.output_data.is_some()) - .unwrap_or(false) - { - return Err(Error::invalid_params( - "the CKB indexer doesn't support data filtering.", + "doesn't support search_key.script_search_mode partial search mode", )); } @@ -556,6 +545,11 @@ impl IndexerHandle { "doesn't support search_key.filter.script_len_range parameter", )); } + if filter.output_data.is_some() { + return Err(Error::invalid_params( + "doesn't support search_key.filter.output_data parameter", + )); + } if filter.output_data_len_range.is_some() { return Err(Error::invalid_params( "doesn't support search_key.filter.output_data_len_range parameter", @@ -812,7 +806,7 @@ impl IndexerHandle { .unwrap_or(false) { return Err(Error::invalid_params( - "the CKB indexer doesn't support script partial search mode", + "doesn't support search_key.script_search_mode partial search mode", )); }