General cleanup for the docs

This commit is contained in:
Alekos Filini
2020-08-31 10:49:44 +02:00
parent d61e974dbe
commit c0867a6adc
23 changed files with 305 additions and 201 deletions

View File

@@ -23,6 +23,7 @@
// SOFTWARE.
use std::collections::HashSet;
use std::fmt;
use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
@@ -116,7 +117,7 @@ impl CompactFilters {
})
}
fn process_tx<D: BatchDatabase + DatabaseUtils>(
fn process_tx<D: BatchDatabase>(
&self,
database: &mut D,
tx: &Transaction,
@@ -207,7 +208,7 @@ impl OnlineBlockchain for CompactFiltersBlockchain {
vec![Capability::FullHistory].into_iter().collect()
}
fn setup<D: BatchDatabase + DatabaseUtils, P: 'static + Progress>(
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
_stop_gap: Option<usize>, // TODO: move to electrum and esplora only
database: &mut D,
@@ -460,6 +461,14 @@ pub enum CompactFiltersError {
Global(Box<crate::error::Error>),
}
impl fmt::Display for CompactFiltersError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl std::error::Error for CompactFiltersError {}
macro_rules! impl_error {
( $from:ty, $to:ident ) => {
impl std::convert::From<$from> for CompactFiltersError {

View File

@@ -257,7 +257,7 @@ impl Peer {
*self.connected.read().unwrap()
}
pub fn reader_thread(
fn reader_thread(
network: Network,
connection: TcpStream,
reader_thread_responses: Arc<RwLock<ResponsesMap>>,

View File

@@ -33,7 +33,7 @@ use electrum_client::{Client, ElectrumApi};
use self::utils::{ELSGetHistoryRes, ELSListUnspentRes, ElectrumLikeSync};
use super::*;
use crate::database::{BatchDatabase, DatabaseUtils};
use crate::database::BatchDatabase;
use crate::error::Error;
use crate::FeeRate;
@@ -73,7 +73,7 @@ impl OnlineBlockchain for ElectrumBlockchain {
.collect()
}
fn setup<D: BatchDatabase + DatabaseUtils, P: Progress>(
fn setup<D: BatchDatabase, P: Progress>(
&self,
stop_gap: Option<usize>,
database: &mut D,

View File

@@ -23,6 +23,7 @@
// SOFTWARE.
use std::collections::{HashMap, HashSet};
use std::fmt;
use futures::stream::{self, StreamExt, TryStreamExt};
@@ -92,7 +93,7 @@ impl OnlineBlockchain for EsploraBlockchain {
.collect()
}
fn setup<D: BatchDatabase + DatabaseUtils, P: Progress>(
fn setup<D: BatchDatabase, P: Progress>(
&self,
stop_gap: Option<usize>,
database: &mut D,
@@ -358,6 +359,14 @@ pub enum EsploraError {
TransactionNotFound(Txid),
}
impl fmt::Display for EsploraError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl std::error::Error for EsploraError {}
impl From<reqwest::Error> for EsploraError {
fn from(other: reqwest::Error) -> Self {
EsploraError::Reqwest(other)

View File

@@ -29,24 +29,29 @@ use std::sync::Arc;
use bitcoin::{Transaction, Txid};
use crate::database::{BatchDatabase, DatabaseUtils};
use crate::database::BatchDatabase;
use crate::error::Error;
use crate::FeeRate;
pub mod utils;
pub(crate) mod utils;
#[cfg(feature = "electrum")]
#[cfg_attr(docsrs, doc(cfg(feature = "electrum")))]
pub mod electrum;
#[cfg(feature = "electrum")]
pub use self::electrum::ElectrumBlockchain;
#[cfg(feature = "esplora")]
#[cfg_attr(docsrs, doc(cfg(feature = "esplora")))]
pub mod esplora;
#[cfg(feature = "esplora")]
pub use self::esplora::EsploraBlockchain;
#[cfg(feature = "compact_filters")]
#[cfg_attr(docsrs, doc(cfg(feature = "compact_filters")))]
pub mod compact_filters;
#[cfg(feature = "compact_filters")]
pub use self::compact_filters::CompactFiltersBlockchain;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Capability {
@@ -76,13 +81,13 @@ impl Blockchain for OfflineBlockchain {
pub trait OnlineBlockchain: Blockchain {
fn get_capabilities(&self) -> HashSet<Capability>;
fn setup<D: BatchDatabase + DatabaseUtils, P: 'static + Progress>(
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
stop_gap: Option<usize>,
database: &mut D,
progress_update: P,
) -> Result<(), Error>;
fn sync<D: BatchDatabase + DatabaseUtils, P: 'static + Progress>(
fn sync<D: BatchDatabase, P: 'static + Progress>(
&self,
stop_gap: Option<usize>,
database: &mut D,
@@ -163,7 +168,7 @@ impl<T: OnlineBlockchain> OnlineBlockchain for Arc<T> {
maybe_await!(self.deref().get_capabilities())
}
fn setup<D: BatchDatabase + DatabaseUtils, P: 'static + Progress>(
fn setup<D: BatchDatabase, P: 'static + Progress>(
&self,
stop_gap: Option<usize>,
database: &mut D,
@@ -172,7 +177,7 @@ impl<T: OnlineBlockchain> OnlineBlockchain for Arc<T> {
maybe_await!(self.deref().setup(stop_gap, database, progress_update))
}
fn sync<D: BatchDatabase + DatabaseUtils, P: 'static + Progress>(
fn sync<D: BatchDatabase, P: 'static + Progress>(
&self,
stop_gap: Option<usize>,
database: &mut D,

View File

@@ -67,7 +67,7 @@ pub trait ElectrumLikeSync {
// Provided methods down here...
fn electrum_like_setup<D: BatchDatabase + DatabaseUtils, P: Progress>(
fn electrum_like_setup<D: BatchDatabase, P: Progress>(
&self,
stop_gap: Option<usize>,
database: &mut D,
@@ -196,7 +196,7 @@ pub trait ElectrumLikeSync {
Ok(())
}
fn check_tx_and_descendant<D: DatabaseUtils + BatchDatabase>(
fn check_tx_and_descendant<D: BatchDatabase>(
&self,
database: &mut D,
txid: &Txid,
@@ -320,7 +320,7 @@ pub trait ElectrumLikeSync {
Ok(to_check_later)
}
fn check_history<D: DatabaseUtils + BatchDatabase>(
fn check_history<D: BatchDatabase>(
&self,
database: &mut D,
script_pubkey: Script,