Skip to content

Commit

Permalink
Disable existing Compact Filters module
Browse files Browse the repository at this point in the history
This commit comments out existing compact filters module so only
nakamoto dependencies get compiled with compact_filters features.
  • Loading branch information
rajarshimaitra committed Oct 13, 2022
1 parent fc7fa22 commit 0a14d45
Show file tree
Hide file tree
Showing 8 changed files with 2,302 additions and 2,297 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ verify = ["bitcoinconsensus"]
default = ["key-value-db", "electrum"]
sqlite = ["rusqlite", "ahash"]
sqlite-bundled = ["sqlite", "rusqlite/bundled"]
compact_filters = ["rocksdb", "socks", "cc", "nakamoto"]
compact_filters = ["nakamoto"]
key-value-db = ["sled"]
all-keys = ["keys-bip39"]
keys-bip39 = ["bip39"]
Expand Down
77 changes: 41 additions & 36 deletions examples/compact_filters_balance.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
// Bitcoin Dev Kit
// Written in 2020 by Alekos Filini <[email protected]>
//
// Copyright (c) 2020-2021 Bitcoin Dev Kit Developers
//
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// You may not use this file except in accordance with one or both of these
// licenses.
// // Bitcoin Dev Kit
// // Written in 2020 by Alekos Filini <[email protected]>
// //
// // Copyright (c) 2020-2021 Bitcoin Dev Kit Developers
// //
// // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
// // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// // You may not use this file except in accordance with one or both of these
// // licenses.

use bdk::blockchain::compact_filters::*;
use bdk::database::MemoryDatabase;
use bdk::*;
use bitcoin::*;
use blockchain::compact_filters::CompactFiltersBlockchain;
use blockchain::compact_filters::CompactFiltersError;
use log::info;
use std::sync::Arc;
// use bdk::blockchain::compact_filters::*;
// use bdk::database::MemoryDatabase;
// use bdk::*;
// use bitcoin::*;
// use blockchain::compact_filters::CompactFiltersBlockchain;
// use blockchain::compact_filters::CompactFiltersError;
// use log::info;
// use std::sync::Arc;

/// This will return wallet balance using compact filters
/// Requires a synced local bitcoin node 0.21 running on testnet with blockfilterindex=1 and peerblockfilters=1
fn main() -> Result<(), CompactFiltersError> {
env_logger::init();
info!("start");
// /// This will return wallet balance using compact filters
// /// Requires a synced local bitcoin node 0.21 running on testnet with blockfilterindex=1 and peerblockfilters=1
// fn main() -> Result<(), CompactFiltersError> {
// env_logger::init();
// info!("start");

let num_threads = 4;
let mempool = Arc::new(Mempool::default());
let peers = (0..num_threads)
.map(|_| Peer::connect("localhost:18333", Arc::clone(&mempool), Network::Testnet))
.collect::<Result<_, _>>()?;
let blockchain = CompactFiltersBlockchain::new(peers, "./wallet-filters", Some(500_000))?;
info!("done {:?}", blockchain);
let descriptor = "wpkh(tpubD6NzVbkrYhZ4X2yy78HWrr1M9NT8dKeWfzNiQqDdMqqa9UmmGztGGz6TaLFGsLfdft5iu32gxq1T4eMNxExNNWzVCpf9Y6JZi5TnqoC9wJq/*)";
// let num_threads = 4;
// let mempool = Arc::new(Mempool::default());
// let peers = (0..num_threads)
// .map(|_| Peer::connect("localhost:18333", Arc::clone(&mempool), Network::Testnet))
// .collect::<Result<_, _>>()?;
// let blockchain = CompactFiltersBlockchain::new(peers, "./wallet-filters", Some(500_000))?;
// info!("done {:?}", blockchain);
// let descriptor = "wpkh(tpubD6NzVbkrYhZ4X2yy78HWrr1M9NT8dKeWfzNiQqDdMqqa9UmmGztGGz6TaLFGsLfdft5iu32gxq1T4eMNxExNNWzVCpf9Y6JZi5TnqoC9wJq/*)";

// let database = MemoryDatabase::default();
// let wallet = Arc::new(Wallet::new(descriptor, None, Network::Testnet, database).unwrap());
// wallet.sync(&blockchain, SyncOptions::default()).unwrap();
// info!("balance: {}", wallet.get_balance()?);
// Ok(())
// }

// TODO make a nakamoto example
fn main() {

let database = MemoryDatabase::default();
let wallet = Arc::new(Wallet::new(descriptor, None, Network::Testnet, database).unwrap());
wallet.sync(&blockchain, SyncOptions::default()).unwrap();
info!("balance: {}", wallet.get_balance()?);
Ok(())
}
Loading

0 comments on commit 0a14d45

Please sign in to comment.