Skip to content

Commit

Permalink
Merge branch 'zmq' into new-index
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Nov 25, 2024
2 parents 6261aa8 + a63c063 commit 5061387
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 34 deletions.
195 changes: 193 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 @@ -57,6 +57,7 @@ tokio = { version = "1", features = ["sync", "macros"] }

# optional dependencies for electrum-discovery
electrum-client = { version = "0.8", optional = true }
zmq = "0.10.0"


[dev-dependencies]
Expand Down
10 changes: 8 additions & 2 deletions src/bin/electrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern crate log;

extern crate electrs;

use crossbeam_channel::{self as channel};
use error_chain::ChainedError;
use std::process;
use std::sync::{Arc, RwLock};
Expand All @@ -15,7 +16,7 @@ use electrs::{
electrum::RPC as ElectrumRPC,
errors::*,
metrics::Metrics,
new_index::{precache, ChainQuery, FetchFrom, Indexer, Mempool, Query, Store},
new_index::{precache, zmq, ChainQuery, FetchFrom, Indexer, Mempool, Query, Store},
rest,
signal::Waiter,
};
Expand All @@ -41,10 +42,15 @@ fn fetch_from(config: &Config, store: &Store) -> FetchFrom {
}

fn run_server(config: Arc<Config>) -> Result<()> {
let signal = Waiter::start();
let (block_hash_notify, block_hash_receive) = channel::bounded(1);
let signal = Waiter::start(block_hash_receive);
let metrics = Metrics::new(config.monitoring_addr);
metrics.start();

if let Some(zmq_addr) = config.zmq_addr.as_ref() {
zmq::start(&format!("tcp://{zmq_addr}"), block_hash_notify);
}

let daemon = Arc::new(Daemon::new(
&config.daemon_dir,
&config.blocks_dir,
Expand Down
18 changes: 10 additions & 8 deletions src/bin/tx-fingerprint-stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
util::has_prevout,
};

let signal = Waiter::start();
let signal = Waiter::start(crossbeam_channel::never());
let config = Config::from_args();
let store = Arc::new(Store::open(&config.db_path.join("newindex"), &config));

Expand Down Expand Up @@ -83,13 +83,15 @@ fn main() {

//info!("{:?},{:?}", txid, blockid);

let prevouts = chain.lookup_txos(
tx.input
.iter()
.filter(|txin| has_prevout(txin))
.map(|txin| txin.previous_output)
.collect(),
).unwrap();
let prevouts = chain
.lookup_txos(
tx.input
.iter()
.filter(|txin| has_prevout(txin))
.map(|txin| txin.previous_output)
.collect(),
)
.unwrap();

let total_out: u64 = tx.output.iter().map(|out| out.value.to_sat()).sum();
let small_out = tx
Expand Down
Loading

0 comments on commit 5061387

Please sign in to comment.