Skip to content

Commit

Permalink
feat: make ClosestNodes public
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Nov 29, 2024
1 parent 96714d2 commit 927e44f
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 9 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ dashmap = "6.1"
## Enable [Dht::as_async()] to use [async_dht::AsyncDht]
async = ["flume/async"]

## Private feature to export ClosestNodes struct. Not a public API.
__private_simulation = []

default = []

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion docs/simulation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
ctrlc = "3.4.5"
mainline = { version = "3.0.1", path = "../..", features = ["__private_simulation"] }
mainline = { version = "3.0.1", path = "../.." }
num_cpus = "1.16.0"
plotters = "0.3.7"
statrs = "0.17.1"
1 change: 0 additions & 1 deletion src/common/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ impl Node {
}
}

#[cfg(any(test, feature = "__private_simulation"))]
/// Create a node that is unique per `i` as it has a random Id and sets IP and port to `i`
pub fn unique(i: usize) -> Node {
use std::net::Ipv4Addr;
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod server;

pub use crate::common::{Id, MutableItem, Node};
pub use dht::{Dht, Settings, Testnet};
pub use rpc::ClosestNodes;

pub use bytes::Bytes;
pub use ed25519_dalek::SigningKey;
Expand All @@ -23,6 +24,3 @@ pub mod errors {
//! Exported errors
pub use super::rpc::PutError;
}

#[cfg(feature = "__private_simulation")]
pub use rpc::ClosestNodes;
2 changes: 1 addition & 1 deletion src/rpc/closest_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl ClosestNodes {
}

/// Take enough nodes closest to the target, until the following are satisfied:
/// 1. At least the closest [k][MAX_BUCKET_SIZE_K].
/// 1. At least the closest `k` nodes (20).
/// 2. The last node should be at a distance `edk` which is the expected distance of the 20th
/// node given previous estimations of the DHT size.
/// 3. The number of subnets with uniqu e6 bits prefix in nodes ipv4 addresses match or exceeds
Expand Down

0 comments on commit 927e44f

Please sign in to comment.