Skip to content

Commit

Permalink
fix: fix local stake
Browse files Browse the repository at this point in the history
  • Loading branch information
petkodes committed Sep 14, 2023
1 parent 9381d92 commit 4cb090a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions subgraph-radio/src/server/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,11 @@ pub fn calc_ratios(
let mut stakes: Vec<String> = Vec::new();
let mut senders: Vec<String> = Vec::new();

let mut matched_once = false;

for att in temp_attestations.iter() {
if local_ppoi.is_some() && att.ppoi.as_str() == local_ppoi.unwrap() {
matched_once = true;
stakes.push(format!("{}*", att.stake_weight + local_stake as i64));
senders.push(format!("{}*", att.senders.len() + 1));
} else {
Expand All @@ -166,6 +169,10 @@ pub fn calc_ratios(
}

// Add zeros at the end if there is no local attestation
if local_ppoi.is_some() && !matched_once {
stakes.push(format!("{}*", local_stake));
}

if local_ppoi.is_none() {
stakes.push("0*".to_string());
senders.push("0*".to_string());
Expand Down

0 comments on commit 4cb090a

Please sign in to comment.