Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use beacon recip table rather than last beacon table for active beaconing gateways #795

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions iot_verifier/src/last_beacon_reciprocity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ impl LastBeaconReciprocity {
.await?)
}

pub async fn get_all_since<'c, E>(
executor: E,
timestamp: DateTime<Utc>,
) -> anyhow::Result<Vec<Self>>
where
E: sqlx::Executor<'c, Database = sqlx::Postgres> + 'c,
{
Ok(
sqlx::query_as::<_, Self>(
r#" select * from last_beacon_recip where timestamp >= $1; "#,
)
.bind(timestamp)
.fetch_all(executor)
.await?,
)
}

pub async fn update_last_timestamp(
txn: &mut Transaction<'_, Postgres>,
id: &PublicKeyBinary,
Expand Down
4 changes: 2 additions & 2 deletions iot_verifier/src/tx_scaler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
gateway_updater::MessageReceiver,
hex_density::{compute_hex_density_map, GlobalHexMap, HexDensityMap},
last_beacon::LastBeacon,
last_beacon_reciprocity::LastBeaconReciprocity,
};
use chrono::{DateTime, Duration, Utc};
use futures::future::LocalBoxFuture;
Expand Down Expand Up @@ -103,7 +103,7 @@ impl Server {
) -> anyhow::Result<HashMap<PublicKeyBinary, DateTime<Utc>>> {
let interactivity_deadline = now - Duration::minutes(HIP_17_INTERACTIVITY_LIMIT);
Ok(
LastBeacon::get_all_since(&self.pool, interactivity_deadline)
LastBeaconReciprocity::get_all_since(&self.pool, interactivity_deadline)
.await?
.into_iter()
.map(|beacon| (beacon.id, beacon.timestamp))
Expand Down
Loading