Skip to content

Commit

Permalink
add permutation of entry winners and fix to one winning score
Browse files Browse the repository at this point in the history
  • Loading branch information
tee8z committed Oct 6, 2024
1 parent bed75c3 commit 2fd6555
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 1,085 deletions.
53 changes: 46 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion daemon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "daemon"
version = "1.1.0"
version = "1.2.0"
edition = "2021"
repository = "https://github.com/tee8z/noaa-data-pipeline"

Expand Down
3 changes: 2 additions & 1 deletion oracle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oracle"
version = "1.1.0"
version = "1.2.0"
edition = "2021"
repository = "https://github.com/tee8z/noaa-data-pipeline"

Expand Down Expand Up @@ -34,6 +34,7 @@ num_cpus = "1.16.0"
openssl = { version = "0.10.60", features = ["vendored"] }
pem-rfc7468 = { version = "0.7.0", features = ["alloc"] }
rand = "0.8.5"
rayon = "1.8"
regex = "1.10.3"
rustix = "0.38.19"
scooby = "0.5.0"
Expand Down
6 changes: 3 additions & 3 deletions oracle/src/db/event_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,15 @@ impl EventData {
.flat_map(|(a, b, c, d, e)| {
let temp_low = match c {
Some(c) => Value::Text(c.to_string()),
None => Value::Null,
_ => Value::Null,
};
let temp_high = match d {
Some(d) => Value::Text(d.to_string()),
None => Value::Null,
_ => Value::Null,
};
let wind_speed = match e {
Some(e) => Value::Text(e.to_string()),
None => Value::Null,
_ => Value::Null,
};
vec![
Value::Text(a.to_string()),
Expand Down
16 changes: 4 additions & 12 deletions oracle/src/db/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::BTreeMap;

use anyhow::anyhow;
use dlctix::bitcoin::{hashes::sha256, XOnlyPublicKey};
use dlctix::musig2::secp256k1::schnorr::Signature;
Expand Down Expand Up @@ -43,8 +41,6 @@ pub struct CreateEvent {
pub number_of_values_per_entry: usize,
/// Total number of allowed entries into the event
pub total_allowed_entries: usize,
/// Total amount of places that are part of the winnings split
pub number_of_places_win: usize,
/// Add a coordinator that will use the event entries in a competition
pub coordinator: Option<CoordinatorInfo>,
}
Expand All @@ -57,16 +53,14 @@ pub struct CreateEventMessage {
/// Time at which the attestation will be added to the event, needs to be after the observation date
pub signing_date: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
/// Date of when the weather observations occured (midnight UTC), all entries must be made before this time
/// Date of when the weather observations occurred (midnight UTC), all entries must be made before this time
pub observation_date: OffsetDateTime,
/// NOAA observation stations used in this event
pub locations: Vec<String>,
/// The number of values that can be selected per entry in the event (default to number_of_locations * 3, (temp_low, temp_high, wind_speed))
pub number_of_values_per_entry: usize,
/// Total number of allowed entries into the event
pub total_allowed_entries: usize,
/// Total amount of places that are part of the winnings split
pub number_of_places_win: usize,
}

impl CreateEventMessage {
Expand All @@ -86,7 +80,6 @@ impl From<CreateEvent> for CreateEventMessage {
locations: value.locations,
number_of_values_per_entry: value.number_of_values_per_entry,
total_allowed_entries: value.total_allowed_entries,
number_of_places_win: value.number_of_places_win,
}
}
}
Expand Down Expand Up @@ -138,9 +131,8 @@ impl CreateEventData {
event.observation_date.format(&Rfc3339).unwrap()
));
}

let possible_user_outcomes: Vec<BTreeMap<usize, Vec<usize>>> =
generate_ranked_players(event.total_allowed_entries, event.number_of_places_win);
let possible_user_outcomes: Vec<Vec<usize>> =
generate_winner_permutations(event.total_allowed_entries);
info!("user outcomes: {:?}", possible_user_outcomes);

let outcome_messages: Vec<Vec<u8>> = generate_outcome_messages(possible_user_outcomes);
Expand Down Expand Up @@ -168,7 +160,7 @@ impl CreateEventData {
signing_date: event.signing_date,
nonce,
total_allowed_entries: event.total_allowed_entries as i64,
number_of_places_win: event.number_of_places_win as i64,
number_of_places_win: 1_i64, // Default to 1 winning score to simplify possible outcomes
number_of_values_per_entry: event.number_of_values_per_entry as i64,
locations: event.clone().locations,
event_annoucement,
Expand Down
Loading

0 comments on commit 2fd6555

Please sign in to comment.