Skip to content

Commit

Permalink
Rename to disable for serde default
Browse files Browse the repository at this point in the history
  • Loading branch information
madninja committed Jun 7, 2023
1 parent e875836 commit 506b221
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
6 changes: 4 additions & 2 deletions config/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ timestamp = true

[poc]
# Whether the poc is enabled or not. When a gateway is not on chain (i.e.
# dataonly) set this to false to avoid unneeded RF traffic.
enable = true
# dataonly) set this to false to avoid unneeded RF traffic. Defaults to false.
#
# disable = false

# The uri to fetch entropy for poc beacons
entropy_uri = "http://entropy.iot.mainnet.helium.io:7080"
# The uri for IOT ingest services to deliver beacons and witnesses
Expand Down
14 changes: 7 additions & 7 deletions src/beaconer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ impl MessageSender {
}

pub struct Beaconer {
/// Beacon/Witness handling enabled
enabled: bool,
/// Beacon/Witness handling disabled
disabled: bool,
/// keypair to sign reports with
keypair: Arc<Keypair>,
/// gateway packet transmit message queue
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Beaconer {
let entropy_uri = settings.poc.entropy_uri.clone();
let keypair = settings.keypair.clone();
let region_params = region_watcher::current_value(&region_watch);
let enabled = settings.poc.enable;
let disabled = settings.poc.disable;

Self {
keypair,
Expand All @@ -92,14 +92,14 @@ impl Beaconer {
region_params,
poc_ingest_uri,
entropy_uri,
enabled,
disabled,
}
}

pub async fn run(&mut self, shutdown: &triggered::Listener) -> Result {
info!(
beacon_interval = self.interval.as_secs(),
enabled = self.enabled,
disabled = self.disabled,
"starting"
);

Expand Down Expand Up @@ -203,7 +203,7 @@ impl Beaconer {
}

async fn handle_beacon_tick(&mut self) {
if !self.enabled {
if self.disabled {
return;
}
match self.mk_beacon().await {
Expand All @@ -224,7 +224,7 @@ impl Beaconer {
}

async fn handle_received_beacon(&mut self, packet: PacketUp) {
if !self.enabled {
if self.disabled {
return;
}
if let Some(last_beacon) = &self.last_beacon {
Expand Down
8 changes: 2 additions & 6 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ impl tracing_subscriber::fmt::time::FormatTime for TimeFormatter {
#[derive(Debug, Deserialize, Clone)]
pub struct PocSettings {
// Enable/disable poc related activities (baecon/witness)
#[serde(default = "default_poc_enable")]
pub enable: bool,
#[serde(default)]
pub disable: bool,
/// Entropy URL.
#[serde(with = "http_serde::uri")]
pub entropy_uri: Uri,
Expand Down Expand Up @@ -146,10 +146,6 @@ fn default_api() -> ListenAddress {
ListenAddress::Address("127.0.0.1:4467".to_string())
}

fn default_poc_enable() -> bool {
true
}

fn default_poc_interval() -> u64 {
// every 6 hours
6 * 3600
Expand Down

0 comments on commit 506b221

Please sign in to comment.