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: customize index rule #57

Merged
merged 3 commits into from
Aug 29, 2022
Merged

feat: customize index rule #57

merged 3 commits into from
Aug 29, 2022

Conversation

quake
Copy link
Member

@quake quake commented Jul 28, 2022

Indexer will index all txs and store all data in local folder by default, howerver users may want to customize filter rules to reduce storage costs ( #51 ), this PR add --block-filter and --cell-filter option to meet that need.

The rule is written in rhai syntax and indexer expose the following variables to the rule: block, output and output_data.

example 1: only index the txs which block height is greater than 1000000

RUST_LOG=info ./target/release/ckb-indexer -s /tmp/ckb-indexer-test --block-filter 'block.header.number.to_uint() > "1000000".to_uint()'

example 2: only index the txs which output script is a specific type

RUST_LOG=info ./target/release/ckb-indexer -s /tmp/ckb-indexer-test --cell-filter 'let script = output.lock; script.code_hash == "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" && script.hash_type == "type" && script.args == "0xa897829e60ee4e3fb0e4abe65549ec4a5ddafad7"'

@quake quake requested a review from doitian July 28, 2022 01:48
@quake quake force-pushed the quake/customize-rule branch from ee45f6f to 91c1ab5 Compare July 29, 2022 00:29
@quake quake merged commit dcb939d into master Aug 29, 2022
@quake quake deleted the quake/customize-rule branch October 15, 2022 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants