Skip to content

Commit 959484b

Browse files
committed
refactor(rpc): Update bitcoind_client to v0.1.0
- also rebased changes
1 parent f037259 commit 959484b

3 files changed

Lines changed: 10 additions & 30 deletions

File tree

crates/bitcoind_rpc/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ workspace = true
1717

1818
[dependencies]
1919
bitcoin = { version = "0.32.0", default-features = false }
20-
bdk-bitcoind-client ={ git = "https://github.com/bitcoindevkit/bdk-bitcoind-client", rev = "06526db5c25047b61d29f81b25cfee7bd0f3abc8"}
20+
bdk_bitcoind_client ={ version = "0.1.0", default-features = false }
2121
bdk_core = { path = "../core", version = "0.6.1", default-features = false }
2222

2323
[dev-dependencies]
@@ -29,7 +29,9 @@ bdk_chain = { path = "../chain" }
2929
default = ["std", "bitcoind_28_0"]
3030
std = ["bitcoin/std", "bdk_core/std"]
3131
serde = ["bitcoin/serde", "bdk_core/serde"]
32-
bitcoind_28_0 =["bdk-bitcoind-client/28_0"]
32+
bitcoind_28_0 =["bdk_bitcoind_client/28_0"]
33+
bitcoind_29_0 = ["bdk_bitcoind_client/29_0"]
34+
bitcoind_30_0 = ["bdk_bitcoind_client/30_0"]
3335

3436
[[example]]
3537
name = "filter_iter"

crates/bitcoind_rpc/src/lib.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ fn poll(
354354
PollResponse::AgreementFound(res, cp) => {
355355
// When a reorg happens, the agreement point drops below `last_cp`. We
356356
// override `start_height` so the emitter revisits the invalidated heights.
357-
if (res.height as u32) < emitter.start_height
358-
&& (res.height as u32) < emitter.last_cp.height()
359-
{
357+
if res.height < emitter.start_height && res.height < emitter.last_cp.height() {
360358
emitter.start_height = res.height as _;
361359
}
362360
// get rid of evicted blocks
@@ -373,28 +371,6 @@ fn poll(
373371
}
374372
}
375373

376-
/// Extends [`bdk_bitcoind_client::Error`].
377-
pub trait BitcoindRpcErrorExt {
378-
/// Returns whether the error is a "not found" error.
379-
///
380-
/// This is useful since [`Emitter`] emits [`Result<_, bdk_bitcoind_client::Error>`]s as
381-
/// [`Iterator::Item`].
382-
fn is_not_found_error(&self) -> bool;
383-
}
384-
385-
impl BitcoindRpcErrorExt for bdk_bitcoind_client::Error {
386-
fn is_not_found_error(&self) -> bool {
387-
if let bdk_bitcoind_client::Error::JsonRpc(bdk_bitcoind_client::jsonrpc::Error::Rpc(
388-
rpc_err,
389-
)) = self
390-
{
391-
rpc_err.code == -5
392-
} else {
393-
false
394-
}
395-
}
396-
}
397-
398374
#[cfg(test)]
399375
#[cfg_attr(coverage_nightly, coverage(off))]
400376
mod test {

crates/bitcoind_rpc/tests/test_emitter.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,11 @@ fn test_expect_tx_evicted() -> anyhow::Result<()> {
660660
fn test_sync_with_new_emitter_after_reorg() -> anyhow::Result<()> {
661661
let env = TestEnv::new()?;
662662
let (mut local_chain, _) = LocalChain::from_genesis(env.genesis_hash()?);
663-
let client = ClientExt::get_rpc_client(&env)?;
663+
let client_1 = ClientExt::get_rpc_client(&env)?;
664664

665665
env.mine_blocks(110, None)?;
666666

667-
let mut emitter = Emitter::new(&client, local_chain.tip(), 0, NO_EXPECTED_MEMPOOL_TXS);
667+
let mut emitter = Emitter::new(client_1, local_chain.tip(), 0, NO_EXPECTED_MEMPOOL_TXS);
668668
while let Some(emission) = emitter.next_block()? {
669669
let _ = local_chain.apply_update(emission.checkpoint)?;
670670
}
@@ -674,9 +674,11 @@ fn test_sync_with_new_emitter_after_reorg() -> anyhow::Result<()> {
674674

675675
env.reorg(6)?;
676676

677+
let client_2 = ClientExt::get_rpc_client(&env)?;
678+
677679
// New emitter with start_height = tip height (common caller pattern).
678680
let mut emitter = Emitter::new(
679-
&client,
681+
client_2,
680682
local_chain.tip(),
681683
tip_height,
682684
NO_EXPECTED_MEMPOOL_TXS,

0 commit comments

Comments
 (0)