helium / oracles

Oracles for Helium subDAOs
Apache License 2.0
17 stars 18 forks source link

Mobile Coverage points calculator #824

Closed michaeldjeffrey closed 3 weeks ago

michaeldjeffrey commented 1 month ago

Many changes to the rewards algorithm are contained in and across many HIPs. The blog post MOBILE Proof of Coverage contains a more thorough explanation of many of them. It is not exhaustive, but a great place to start.

Please comment if...

Example Usage

type RadioId = (PublicKeyBinary, Some(String));

pub async fn coverage_points(
    &mut self,
    radio_id: &RadioId,
) -> anyhow::Result<coverage_point_calculator::CoveragePoints> {
    let pubkey = &radio_id.0;
    let average = self.speedtest_averages.get_average(pubkey).unwrap();
    let speedtests = self.speedtests.get(&radio_id).expect("speedtests").clone();
    let radio_type = self.radio_type(&radio_id);
    let trust_scores = self
        .trust_scores
        .get(&radio_id)
        .expect("trust scores")
        .clone();
    let verified = self.radio_threshold_verified(&radio_id);
    let ranked_coverage = self.coverage_map.hexes(&radio_id);

    let coverage_points = coverage_point_calculator::CoveragePoints::new(
        radio_type,
        RadioThreshold::Verified,
        speedtests,
        location_trust_scores,
        ranked_coverage,
    )?;

    Ok(coverage_points)
}

Fields:

Notable Conditions:

bbalser commented 1 month ago

My understanding is the caller will call make_rewardable_radio and then take the output and call calculate_coverage_points. Looking through the code, some of the calculations are done in the first function and some in the second. I don't understand the value of this being 2 steps. Why not just a single function that does everything?

michaeldjeffrey commented 1 month ago

Why not just a single function that does everything?

Having the Radio and CoveragePoints separate was an artifact of the way I started. Now that we're closing in on the end, I agree it makes sense to provide a single function as the interface for calculating coverage points.

In doing so, it also revealed that many of the intermediary structs were no longer needed. They have been removed in lieu of functions that I think better describe the problem.