Skip to content

Commit

Permalink
refactor!: remove the StatelessPeerStore
Browse files Browse the repository at this point in the history
Bootstrapping peers every sync should be discouraged, and considering there is no
in-memory option for block headers, the `StatelessPeerStore` is mostly for development.
This should reduce future maintanence and remove a poor option for developers.
  • Loading branch information
rustaceanrob committed Jan 10, 2025
1 parent e170741 commit ea33352
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 176 deletions.
19 changes: 0 additions & 19 deletions src/db/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::fmt::Debug;

use crate::impl_sourceless_error;

/// Errors when initializing a SQL-based backend.
#[cfg(feature = "database")]
#[derive(Debug)]
Expand Down Expand Up @@ -171,20 +169,3 @@ impl core::fmt::Display for UnitPeerStoreError {
}
}
}

/// Errors for the in-memory [`PeerStore`](crate) implementation.
#[derive(Debug)]
pub enum StatelessPeerStoreError {
/// There were no peers found.
NoPeers,
}

impl core::fmt::Display for StatelessPeerStoreError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StatelessPeerStoreError::NoPeers => write!(f, "no peers in the database."),
}
}
}

impl_sourceless_error!(StatelessPeerStoreError);
2 changes: 0 additions & 2 deletions src/db/memory/mod.rs

This file was deleted.

147 changes: 0 additions & 147 deletions src/db/memory/peers.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use bitcoin::p2p::ServiceFlags;

/// Errors a database backend may produce.
pub mod error;
/// In-memory persistence trait implementations for light-weight nodes running on constrained or semi-trusted setups.
pub mod memory;
/// Persistence traits defined with SQL Lite to store data between sessions.
#[cfg(feature = "database")]
pub mod sqlite;
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ pub use chain::checkpoints::{
HeaderCheckpoint, MAINNET_HEADER_CP, SIGNET_HEADER_CP, TESTNET4_HEADER_CP,
};

#[doc(inline)]
pub use db::memory::peers::StatelessPeerStore;

#[cfg(feature = "database")]
#[doc(inline)]
pub use db::sqlite::{headers::SqliteHeaderDb, peers::SqlitePeerDb};
Expand Down
5 changes: 2 additions & 3 deletions tests/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use kyoto::{
client::{Client, Receiver},
node::Node,
},
db::memory::peers::StatelessPeerStore,
BlockHash, Event, Log, NodeState, ServiceFlags, SqliteHeaderDb, SqlitePeerDb, TrustedPeer,
};
use tokio::sync::mpsc::UnboundedReceiver;
Expand Down Expand Up @@ -615,9 +614,9 @@ async fn test_signet_syncs() {
let host = (IpAddr::from(Ipv4Addr::new(68, 47, 229, 218)), None);
let builder = kyoto::core::builder::NodeBuilder::new(bitcoin::Network::Signet);
let (node, client) = builder
.add_peers(vec![host.into()])
.add_peer(host)
.add_scripts(set)
.build_with_databases(StatelessPeerStore::new(), ());
.build_with_databases((), ());
tokio::task::spawn(async move { node.run().await });
async fn print_and_sync(mut client: Client) {
loop {
Expand Down

0 comments on commit ea33352

Please sign in to comment.