Skip to content

Commit 5061387

Browse files
committed
Merge branch 'zmq' into new-index
2 parents 6261aa8 + a63c063 commit 5061387

File tree

9 files changed

+302
-34
lines changed

9 files changed

+302
-34
lines changed

Cargo.lock

Lines changed: 193 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ tokio = { version = "1", features = ["sync", "macros"] }
5757

5858
# optional dependencies for electrum-discovery
5959
electrum-client = { version = "0.8", optional = true }
60+
zmq = "0.10.0"
6061

6162

6263
[dev-dependencies]

src/bin/electrs.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ extern crate log;
44

55
extern crate electrs;
66

7+
use crossbeam_channel::{self as channel};
78
use error_chain::ChainedError;
89
use std::process;
910
use std::sync::{Arc, RwLock};
@@ -15,7 +16,7 @@ use electrs::{
1516
electrum::RPC as ElectrumRPC,
1617
errors::*,
1718
metrics::Metrics,
18-
new_index::{precache, ChainQuery, FetchFrom, Indexer, Mempool, Query, Store},
19+
new_index::{precache, zmq, ChainQuery, FetchFrom, Indexer, Mempool, Query, Store},
1920
rest,
2021
signal::Waiter,
2122
};
@@ -41,10 +42,15 @@ fn fetch_from(config: &Config, store: &Store) -> FetchFrom {
4142
}
4243

4344
fn run_server(config: Arc<Config>) -> Result<()> {
44-
let signal = Waiter::start();
45+
let (block_hash_notify, block_hash_receive) = channel::bounded(1);
46+
let signal = Waiter::start(block_hash_receive);
4547
let metrics = Metrics::new(config.monitoring_addr);
4648
metrics.start();
4749

50+
if let Some(zmq_addr) = config.zmq_addr.as_ref() {
51+
zmq::start(&format!("tcp://{zmq_addr}"), block_hash_notify);
52+
}
53+
4854
let daemon = Arc::new(Daemon::new(
4955
&config.daemon_dir,
5056
&config.blocks_dir,

src/bin/tx-fingerprint-stats.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
util::has_prevout,
2222
};
2323

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

@@ -83,13 +83,15 @@ fn main() {
8383

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

86-
let prevouts = chain.lookup_txos(
87-
tx.input
88-
.iter()
89-
.filter(|txin| has_prevout(txin))
90-
.map(|txin| txin.previous_output)
91-
.collect(),
92-
).unwrap();
86+
let prevouts = chain
87+
.lookup_txos(
88+
tx.input
89+
.iter()
90+
.filter(|txin| has_prevout(txin))
91+
.map(|txin| txin.previous_output)
92+
.collect(),
93+
)
94+
.unwrap();
9395

9496
let total_out: u64 = tx.output.iter().map(|out| out.value.to_sat()).sum();
9597
let small_out = tx

0 commit comments

Comments
 (0)