Skip to content

Commit

Permalink
Create and store block filters (#89)
Browse files Browse the repository at this point in the history
* Create a simple filter builder

* Index txid

This is useful for fetching utxos for their txid

* Implement query logic

* query script hashes, not scripts

* Move block filters to a dedicated module

* Document methods

* actually create block filters

* Expose final things to cli
  • Loading branch information
Davidson-Souza authored Nov 21, 2023
1 parent 3713cfb commit 60da291
Show file tree
Hide file tree
Showing 10 changed files with 663 additions and 29 deletions.
17 changes: 15 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"crates/floresta-chain",
"crates/floresta-cli",
"crates/floresta-common",
"crates/floresta-compact-filters",
"crates/floresta-electrum",
"crates/floresta-watch-only",
"crates/floresta-wire",
Expand Down
7 changes: 7 additions & 0 deletions crates/floresta-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn get_req(cmd: &Cli) -> (Vec<Box<RawValue>>, String) {
Methods::ListTransactions => "gettransactions",
Methods::Stop => "stop",
Methods::AddNode { .. } => "addnode",
Methods::GetFilters { .. } => "getblockfilter",
};
let params = match &cmd.methods {
Methods::GetBlockchainInfo => Vec::new(),
Expand Down Expand Up @@ -92,6 +93,9 @@ fn get_req(cmd: &Cli) -> (Vec<Box<RawValue>>, String) {
Methods::AddNode { node } => {
vec![arg(node)]
}
Methods::GetFilters { height } => {
vec![arg(height)]
}
};

(params, method.to_string())
Expand Down Expand Up @@ -182,4 +186,7 @@ pub enum Methods {
/// Usage: addnode <ip:[port]>
#[command(name = "addnode")]
AddNode { node: String },
/// Returns the filters for a given block
#[command(name = "getfilter")]
GetFilters { height: u32 },
}
20 changes: 20 additions & 0 deletions crates/floresta-compact-filters/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "floresta-compact-filters"
version = "0.1.0"
authors = ["Davidson Sousa <[email protected]>"]
edition = "2018"
homepage = "https://github.com/davidson-souza/floresta"
repository = "https://github.com/davidson-souza/floresta"
description = """
BIP158 compact filters for easy rescan of the blockchain in
light clients.
"""

[dependencies]
bitcoin_hashes = "0.11.0"
bitcoin = "0.29"
floresta-common = { path = "../floresta-common" }
floresta-chain = { path = "../floresta-chain", default-features = false }
kv = "0.24.0"
log = "0.4.20"

Loading

0 comments on commit 60da291

Please sign in to comment.