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

feat: add pox_stx_threshold amount to /new_block event data #4524

Merged
merged 5 commits into from Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions stacks-signer/src/client/stacks_client.rs
Expand Up @@ -1143,6 +1143,7 @@ mod tests {
stacked_amt: rand::thread_rng().next_u64() as u128,
weight: 1,
}]),
pox_stx_threshold: None,
};
let stackers_response = GetStackersResponse {
stacker_set: stacker_set.clone(),
Expand Down
1 change: 1 addition & 0 deletions stackslib/src/chainstate/coordinator/tests.rs
Expand Up @@ -511,6 +511,7 @@ impl RewardSetProvider for StubbedRewardSetProvider {
missed_reward_slots: vec![],
},
signers: None,
pox_stx_threshold: None,
})
}

Expand Down
31 changes: 31 additions & 0 deletions stackslib/src/chainstate/stacks/boot/mod.rs
Expand Up @@ -213,6 +213,30 @@ fn hex_deserialize<'de, D: serde::Deserializer<'de>>(
Ok(bytes)
}

fn serialize_optional_u128_as_string<S>(
value: &Option<u128>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match value {
Some(v) => serializer.serialize_str(&v.to_string()),
None => serializer.serialize_none(),
}
}

fn deserialize_optional_u128_from_string<'de, D>(deserializer: D) -> Result<Option<u128>, D::Error>
where
D: serde::Deserializer<'de>,
{
let s: Option<String> = Option::deserialize(deserializer)?;
match s {
Some(str_val) => str_val.parse::<u128>().map(Some).map_err(serde::de::Error::custom),
None => Ok(None),
}
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct NakamotoSignerEntry {
#[serde(serialize_with = "hex_serialize", deserialize_with = "hex_deserialize")]
Expand All @@ -228,6 +252,11 @@ pub struct RewardSet {
#[serde(skip_serializing_if = "Option::is_none", default)]
// only generated for nakamoto reward sets
pub signers: Option<Vec<NakamotoSignerEntry>>,
#[serde(
serialize_with = "serialize_optional_u128_as_string",
deserialize_with = "deserialize_optional_u128_from_string"
)]
pub pox_stx_threshold: Option<u128>,
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -260,6 +289,7 @@ impl RewardSet {
missed_reward_slots: vec![],
},
signers: None,
pox_stx_threshold: None,
}
}

Expand Down Expand Up @@ -843,6 +873,7 @@ impl StacksChainState {
missed_reward_slots: missed_slots,
},
signers: signer_set,
pox_stx_threshold: Some(threshold),
obycode marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down