Update documentation

* Add `warn(missing_docs)` for `bdk_wallet` and `bdk_chain`.
* Add missing documentation.
* Remove `LocalChain::heights` method.
* Remove old TODOs.
This commit is contained in:
志宇
2023-05-29 21:54:53 +08:00
parent cff92111d5
commit 75f8b81d58
8 changed files with 54 additions and 14 deletions

View File

@@ -1,6 +1,8 @@
//! The [`LocalChain`] is a local implementation of [`ChainOracle`].
use core::convert::Infallible;
use alloc::collections::{BTreeMap, BTreeSet};
use alloc::collections::BTreeMap;
use bitcoin::BlockHash;
use crate::{BlockId, ChainOracle};
@@ -59,6 +61,7 @@ impl From<BTreeMap<u32, BlockHash>> for LocalChain {
}
impl LocalChain {
/// Contruct a [`LocalChain`] from a list of [`BlockId`]s.
pub fn from_blocks<B>(blocks: B) -> Self
where
B: IntoIterator<Item = BlockId>,
@@ -73,6 +76,7 @@ impl LocalChain {
&self.blocks
}
/// Get the chain tip.
pub fn tip(&self) -> Option<BlockId> {
self.blocks
.iter()
@@ -158,6 +162,9 @@ impl LocalChain {
Ok(changeset)
}
/// Derives a [`ChangeSet`] that assumes that there are no preceding changesets.
///
/// The changeset returned will record additions of all blocks included in [`Self`].
pub fn initial_changeset(&self) -> ChangeSet {
self.blocks
.iter()
@@ -165,10 +172,6 @@ impl LocalChain {
.collect()
}
pub fn heights(&self) -> BTreeSet<u32> {
self.blocks.keys().cloned().collect()
}
/// Insert a block of [`BlockId`] into the [`LocalChain`].
///
/// # Error
@@ -225,8 +228,11 @@ impl std::error::Error for UpdateNotConnectedError {}
/// Represents a failure when trying to insert a checkpoint into [`LocalChain`].
#[derive(Clone, Debug, PartialEq)]
pub struct InsertBlockNotMatchingError {
/// The checkpoints' height.
pub height: u32,
/// Original checkpoint's block hash.
pub original_hash: BlockHash,
/// Update checkpoint's block hash.
pub update_hash: BlockHash,
}