Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions examples/example_bitcoind_rpc_polling/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ fn main() -> anyhow::Result<()> {

let rpc_client = rpc_args.new_client()?;
let mut emitter = {
let chain = chain.lock().unwrap();
let graph = graph.lock().unwrap();
let chain = chain.lock().expect("mutex poisoned");
let graph = graph.lock().expect("mutex poisoned");
Emitter::new(
&rpc_client,
chain.tip(),
Expand All @@ -163,8 +163,8 @@ fn main() -> anyhow::Result<()> {
while let Some(emission) = emitter.next_block()? {
let height = emission.block_height();

let mut chain = chain.lock().unwrap();
let mut graph = graph.lock().unwrap();
let mut chain = chain.lock().expect("mutex poisoned");
let mut graph = graph.lock().expect("mutex poisoned");

let chain_changeset = chain
.apply_update(emission.checkpoint)
Expand All @@ -179,7 +179,7 @@ fn main() -> anyhow::Result<()> {

// commit staged db changes in intervals
if last_db_commit.elapsed() >= DB_COMMIT_DELAY {
let db = &mut *db.lock().unwrap();
let db = &mut *db.lock().expect("mutex poisoned");
last_db_commit = Instant::now();
if let Some(changeset) = db_stage.take() {
db.append(&changeset)?;
Expand Down Expand Up @@ -224,7 +224,7 @@ fn main() -> anyhow::Result<()> {
.unwrap()
.batch_insert_relevant_unconfirmed(mempool_txs.update);
{
let db = &mut *db.lock().unwrap();
let db = &mut *db.lock().expect("mutex poisoned");
db_stage.merge(ChangeSet {
tx_graph: graph_changeset.tx_graph,
indexer: graph_changeset.indexer,
Expand All @@ -243,8 +243,8 @@ fn main() -> anyhow::Result<()> {

let rpc_client = Arc::new(rpc_args.new_client()?);
let mut emitter = {
let chain = chain.lock().unwrap();
let graph = graph.lock().unwrap();
let chain = chain.lock().expect("mutex poisoned");
let graph = graph.lock().expect("mutex poisoned");
Emitter::new(
rpc_client.clone(),
chain.tip(),
Expand Down Expand Up @@ -306,8 +306,8 @@ fn main() -> anyhow::Result<()> {
let mut db_stage = ChangeSet::default();

for emission in rx {
let mut graph = graph.lock().unwrap();
let mut chain = chain.lock().unwrap();
let mut graph = graph.lock().expect("mutex poisoned");
let mut chain = chain.lock().expect("mutex poisoned");

let (chain_changeset, graph_changeset) = match emission {
Emission::Block(block_emission) => {
Expand Down Expand Up @@ -340,7 +340,7 @@ fn main() -> anyhow::Result<()> {
});

if last_db_commit.elapsed() >= DB_COMMIT_DELAY {
let db = &mut *db.lock().unwrap();
let db = &mut *db.lock().expect("mutex poisoned");
last_db_commit = Instant::now();
if let Some(changeset) = db_stage.take() {
db.append(&changeset)?;
Expand Down
20 changes: 10 additions & 10 deletions examples/example_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
Commands::Generate { .. } => unreachable!("handled by generate command"),
Commands::ChainSpecific(_) => unreachable!("example code should handle this!"),
Commands::Address { addr_cmd } => {
let graph = &mut *graph.lock().unwrap();
let graph = &mut *graph.lock().expect("mutex poisoned");
let index = &mut graph.index;

match addr_cmd {
Expand All @@ -475,7 +475,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(

let ((spk_i, spk), index_changeset) =
spk_chooser(index, Keychain::External).expect("Must exist");
let db = &mut *db.lock().unwrap();
let db = &mut *db.lock().expect("mutex poisoned");
db.append(&ChangeSet {
indexer: index_changeset,
..Default::default()
Expand Down Expand Up @@ -510,8 +510,8 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
}
}
Commands::Balance => {
let graph = &*graph.lock().unwrap();
let chain = &*chain.lock().unwrap();
let graph = &*graph.lock().expect("mutex poisoned");
let chain = &*chain.lock().expect("mutex poisoned");
fn print_balances<'a>(
title_str: &'a str,
items: impl IntoIterator<Item = (&'a str, Amount)>,
Expand Down Expand Up @@ -557,8 +557,8 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
Ok(())
}
Commands::TxOut { txout_cmd } => {
let graph = &*graph.lock().unwrap();
let chain = &*chain.lock().unwrap();
let graph = &*graph.lock().expect("mutex poisoned");
let chain = &*chain.lock().expect("mutex poisoned");
let chain_tip = chain.get_chain_tip()?;
let outpoints = graph.index.outpoints();

Expand Down Expand Up @@ -608,8 +608,8 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
let address = address.require_network(network)?;

let (psbt, change_info) = {
let mut graph = graph.lock().unwrap();
let chain = chain.lock().unwrap();
let mut graph = graph.lock().expect("mutex poisoned");
let chain = chain.lock().expect("mutex poisoned");

// collect assets we can sign for
let mut pks = vec![];
Expand Down Expand Up @@ -648,7 +648,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
// change keychain so future scans will find the tx we're about to broadcast.
// If we're unable to persist this, then we don't want to broadcast.
{
let db = &mut *db.lock().unwrap();
let db = &mut *db.lock().expect("mutex poisoned");
db.append(&ChangeSet {
indexer,
..Default::default()
Expand Down Expand Up @@ -715,7 +715,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
let tx = psbt.extract_tx()?;

if broadcast {
let mut graph = graph.lock().unwrap();
let mut graph = graph.lock().expect("mutex poisoned");

match broadcast_fn(chain_specific, &tx) {
Ok(_) => {
Expand Down
16 changes: 8 additions & 8 deletions examples/example_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn main() -> anyhow::Result<()> {
// Tell the electrum client about the txs and anchors we've already got locally so it doesn't
// re-download .them
{
let graph = graph.lock().unwrap();
let graph = graph.lock().expect("mutex poisoned");
client.populate_tx_cache(graph.graph().full_txs().map(|tx_node| tx_node.tx));
client.populate_anchor_cache(graph.graph().all_anchors().clone());
}
Expand All @@ -141,8 +141,8 @@ fn main() -> anyhow::Result<()> {
..
} => {
let request = {
let graph = &*graph.lock().unwrap();
let chain = &*chain.lock().unwrap();
let graph = &*graph.lock().expect("mutex poisoned");
let chain = &*chain.lock().expect("mutex poisoned");

FullScanRequest::builder()
.chain_tip(chain.tip())
Expand Down Expand Up @@ -193,8 +193,8 @@ fn main() -> anyhow::Result<()> {
..
} => {
// Get a short lock on the tracker to get the spks we're interested in
let graph = graph.lock().unwrap();
let chain = chain.lock().unwrap();
let graph = graph.lock().expect("mutex poisoned");
let chain = chain.lock().expect("mutex poisoned");

if !(all_spks || unused_spks || utxos || unconfirmed) {
unused_spks = true;
Expand Down Expand Up @@ -269,8 +269,8 @@ fn main() -> anyhow::Result<()> {
};

let db_changeset = {
let mut chain = chain.lock().unwrap();
let mut graph = graph.lock().unwrap();
let mut chain = chain.lock().expect("mutex poisoned");
let mut graph = graph.lock().expect("mutex poisoned");

let chain_changeset = chain.apply_update(chain_update.expect("request has chain tip"))?;

Expand All @@ -290,7 +290,7 @@ fn main() -> anyhow::Result<()> {
}
};

let mut db = db.lock().unwrap();
let mut db = db.lock().expect("mutex poisoned");
db.append(&db_changeset)?;
Ok(())
}
6 changes: 3 additions & 3 deletions examples/example_esplora/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ fn main() -> anyhow::Result<()> {
// Get a short lock on the structures to get spks, utxos, and txs that we are interested
// in.
{
let graph = graph.lock().unwrap();
let chain = chain.lock().unwrap();
let graph = graph.lock().expect("mutex poisoned");
let chain = chain.lock().expect("mutex poisoned");
let canonical_view = graph.canonical_view(
&*chain,
local_tip.block_id(),
Expand Down Expand Up @@ -290,7 +290,7 @@ fn main() -> anyhow::Result<()> {
println!();

// We persist the changes
let mut db = db.lock().unwrap();
let mut db = db.lock().expect("mutex poisoned");
db.append(&ChangeSet {
local_chain: local_chain_changeset,
tx_graph: indexed_tx_graph_changeset.tx_graph,
Expand Down