Skip to content

Commit

Permalink
Clarify different queries that can prevent rewarding
Browse files Browse the repository at this point in the history
Unique Connections is the outlying query in that it depends on the start _and_ end of a reward_epoch, while the others only care about the end of the reward_epoch.

The different being, unique connections come in once per day, while the others come in constanyl throughout the day.
  • Loading branch information
michaeldjeffrey committed Dec 16, 2024
1 parent 989ce69 commit 7064e68
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mobile_verifier/src/rewarder/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ use std::ops::Range;
use chrono::{DateTime, Utc};
use sqlx::PgPool;

/// Heartbeats are sent constantly throughout the day.
///
/// If there are heartbeats that exists past the end of the rewardable period,
/// we can know that the heartbeat machinery has been working at least through
/// the period we're attempting to reward.
pub async fn no_cbrs_heartbeats(
pool: &PgPool,
reward_period: &Range<DateTime<Utc>>,
Expand All @@ -17,6 +22,11 @@ pub async fn no_cbrs_heartbeats(
Ok(count == 0)
}

/// Heartbeats are sent constantly throughout the day.
///
/// If there are heartbeats that exists past the end of the rewardable period,
/// we can know that the heartbeat machinery has been working at least through
/// the period we're attempting to reward.
pub async fn no_wifi_heartbeats(
pool: &PgPool,
reward_period: &Range<DateTime<Utc>>,
Expand All @@ -31,6 +41,11 @@ pub async fn no_wifi_heartbeats(
Ok(count == 0)
}

/// Speedtests are sent constantly throughout the day.
///
/// If there are speedtests that exists past the end of the rewardable period,
/// we can know that the speedtests machinery has been working at least through
/// the period we're attempting to reward.
pub async fn no_speedtests(
pool: &PgPool,
reward_period: &Range<DateTime<Utc>>,
Expand All @@ -44,6 +59,10 @@ pub async fn no_speedtests(
Ok(count == 0)
}

/// Unique Connections are submitted once per day,
///
/// We want to make sure we have received a report of unique connections for the
/// period we're attempting to reward.
pub async fn no_unique_connections(
pool: &PgPool,
reward_period: &Range<DateTime<Utc>>,
Expand Down

0 comments on commit 7064e68

Please sign in to comment.