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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stacks-signer/src/client/stacks_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ mod tests {
stacked_amt: rand::thread_rng().next_u64() as u128,
weight: 1,
}]),
pox_ustx_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
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ impl RewardSetProvider for StubbedRewardSetProvider {
missed_reward_slots: vec![],
},
signers: None,
pox_ustx_threshold: None,
})
}

Expand Down
34 changes: 34 additions & 0 deletions stackslib/src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,33 @@ 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),
}
}

fn serialize_u128_as_string<S>(value: &u128, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down Expand Up @@ -248,6 +275,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_ustx_threshold: Option<u128>,
}

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

Expand Down Expand Up @@ -863,6 +896,7 @@ impl StacksChainState {
missed_reward_slots: missed_slots,
},
signers: signer_set,
pox_ustx_threshold: Some(threshold),
}
}

Expand Down