Skip to content

Commit

Permalink
fix: skipping eras without payouts
Browse files Browse the repository at this point in the history
  • Loading branch information
yahortsaryk committed Feb 3, 2025
1 parent b1e349e commit a4f302b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pallets/ddc-verification/src/aggregator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,15 @@ pub(crate) mod json {
pub number_of_gets: u64,
}

impl EHDUsage {
pub fn has_usage(&self) -> bool {
self.stored_bytes > 0 &&
self.transferred_bytes > 0 &&
self.number_of_puts > 0 &&
self.number_of_gets > 0
}
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Encode, Decode)]
pub struct EHDUsagePercent {
#[serde(rename = "storedBytesPercent")]
Expand Down
9 changes: 9 additions & 0 deletions pallets/ddc-verification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,15 @@ pub mod pallet {
if let Some(inspected_ehds) = Self::fetch_last_inspected_ehds(cluster_id) {
for inspected_ehd in inspected_ehds.clone().into_iter().sorted() {
if inspected_ehd.2 > last_paid_era_for_cluster {
let ehd_root =
Self::get_ehd_root(cluster_id, inspected_ehd.clone())
.expect("EHD to be fetched");

let cluster_usage = ehd_root.get_cluster_usage();
if !cluster_usage.has_usage() {
continue;
}

let receipts_by_inspector = Self::fetch_inspection_receipts(
cluster_id,
inspected_ehd.clone(),
Expand Down

0 comments on commit a4f302b

Please sign in to comment.