- Removed and replaced `set_single_recipient` with more general `drain_to` and replaced `maintain_single_recipient` with `allow_shrinking`.
+### Blockchain
+
+- Removed `stop_gap` from `Blockchain` trait and added it to only `ElectrumBlockchain` and `EsploraBlockchain` structs
+
## [v0.9.0] - [v0.8.0]
### Wallet
//!
//! # #[cfg(feature = "esplora")]
//! # {
-//! let esplora_blockchain = EsploraBlockchain::new("...", None);
+//! let esplora_blockchain = EsploraBlockchain::new("...", None, 20);
//! let wallet_esplora: Wallet<AnyBlockchain, _> = Wallet::new(
//! "...",
//! None,
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
- maybe_await!(impl_inner_method!(
- self,
- setup,
- stop_gap,
- database,
- progress_update
- ))
+ maybe_await!(impl_inner_method!(self, setup, database, progress_update))
}
fn sync<D: BatchDatabase, P: 'static + Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
- maybe_await!(impl_inner_method!(
- self,
- sync,
- stop_gap,
- database,
- progress_update
- ))
+ maybe_await!(impl_inner_method!(self, sync, database, progress_update))
}
fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error> {
#[allow(clippy::mutex_atomic)] // Mutex is easier to understand than a CAS loop.
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
- _stop_gap: Option<usize>, // TODO: move to electrum and esplora only
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
fn setup<D: BatchDatabase, P: Progress>(
&self,
- _stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
self.client
- .electrum_like_setup(Some(self.stop_gap), database, progress_update)
+ .electrum_like_setup(self.stop_gap, database, progress_update)
}
fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error> {
//!
//! ```no_run
//! # use bdk::blockchain::esplora::EsploraBlockchain;
-//! let blockchain = EsploraBlockchain::new("https://blockstream.info/testnet/api", None);
+//! let blockchain = EsploraBlockchain::new("https://blockstream.info/testnet/api", None, 20);
//! # Ok::<(), bdk::Error>(())
//! ```
fn setup<D: BatchDatabase, P: Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
maybe_await!(self
.url_client
- .electrum_like_setup(stop_gap, database, progress_update))
+ .electrum_like_setup(self.stop_gap, database, progress_update))
}
fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error> {
#[cfg(feature = "test-esplora")]
crate::bdk_blockchain_tests! {
fn test_instance(test_client: &TestClient) -> EsploraBlockchain {
- EsploraBlockchain::new(&format!("http://{}",test_client.electrsd.esplora_url.as_ref().unwrap()), None)
+ EsploraBlockchain::new(&format!("http://{}",test_client.electrsd.esplora_url.as_ref().unwrap()), None, 20)
}
}
/// [`Blockchain::sync`] defaults to calling this internally if not overridden.
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error>;
/// [`BatchOperations::del_utxo`]: crate::database::BatchOperations::del_utxo
fn sync<D: BatchDatabase, P: 'static + Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
- maybe_await!(self.setup(stop_gap, database, progress_update))
+ maybe_await!(self.setup(database, progress_update))
}
/// Fetch a transaction from the blockchain given its txid
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
- maybe_await!(self.deref().setup(stop_gap, database, progress_update))
+ maybe_await!(self.deref().setup(database, progress_update))
}
fn sync<D: BatchDatabase, P: 'static + Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
- maybe_await!(self.deref().sync(stop_gap, database, progress_update))
+ maybe_await!(self.deref().sync(database, progress_update))
}
fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error> {
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
- stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error> {
self.set_node_synced_height(current_height)?;
- self.sync(stop_gap, database, progress_update)
+ self.sync(database, progress_update)
}
fn sync<D: BatchDatabase, P: 'static + Progress>(
&self,
- _stop_gap: Option<usize>,
db: &mut D,
_progress_update: P,
) -> Result<(), Error> {
fn electrum_like_setup<D: BatchDatabase, P: Progress>(
&self,
- stop_gap: Option<usize>,
+ stop_gap: usize,
db: &mut D,
_progress_update: P,
) -> Result<(), Error> {
let start = Instant::new();
debug!("start setup");
- let stop_gap = stop_gap.unwrap_or(20);
let chunk_size = stop_gap;
let mut history_txs_id = HashSet::new();
// TODO: what if i generate an address first and cache some addresses?
// TODO: we should sync if generating an address triggers a new batch to be stored
if run_setup {
- maybe_await!(self.client.setup(
- None,
- self.database.borrow_mut().deref_mut(),
- progress_update,
- ))?;
+ maybe_await!(self
+ .client
+ .setup(self.database.borrow_mut().deref_mut(), progress_update,))?;
} else {
- maybe_await!(self.client.sync(
- None,
- self.database.borrow_mut().deref_mut(),
- progress_update,
- ))?;
+ maybe_await!(self
+ .client
+ .sync(self.database.borrow_mut().deref_mut(), progress_update,))?;
}
#[cfg(feature = "verify")]
}
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
- _stop_gap: Option<usize>,
_database: &mut D,
_progress_update: P,
) -> Result<(), Error> {