Skip to content

Commit

Permalink
Generate Location from local addresses properly
Browse files Browse the repository at this point in the history
  • Loading branch information
netsirius committed Sep 14, 2024
1 parent 4fc9239 commit fff5345
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ tracing = "0.1"
[features]
default = ["redb", "trace", "websocket"]
local-mode = []
local-simulation = []
network-mode = []
sqlite = ["sqlx"]
trace = ["tracing-subscriber"]
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ pub struct Location(f64);

impl Location {

#[cfg(not(feature = "local-mode"))]
#[cfg(not(feature = "local-simulation"))]
pub fn from_address(addr: &SocketAddr) -> Self {
match addr.ip() {
IpAddr::V4(ipv4) => {
Expand All @@ -808,7 +808,7 @@ impl Location {
}
}

#[cfg(feature = "local-mode")]
#[cfg(feature = "local-simulation")]
pub fn from_address(_addr: &SocketAddr) -> Self {
let random_component: f64 = rand::random();
Location(random_component)
Expand Down

0 comments on commit fff5345

Please sign in to comment.