Skip to content

Commit 3526021

Browse files
committed
Handle set new root on new frozen slots (#66)
1 parent 1cbc348 commit 3526021

File tree

2 files changed

+133
-152
lines changed

2 files changed

+133
-152
lines changed

core/src/alpenglow_consensus/certificate_pool.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ pub enum NewHighestCertificate {
2828
Finalize(Slot),
2929
}
3030

31+
impl NewHighestCertificate {
32+
pub fn is_finalize(&self) -> bool {
33+
matches!(self, NewHighestCertificate::Finalize(_slot))
34+
}
35+
36+
pub fn slot(&self) -> Slot {
37+
match self {
38+
NewHighestCertificate::Notarize(slot) => *slot,
39+
NewHighestCertificate::Skip(slot) => *slot,
40+
NewHighestCertificate::Finalize(slot) => *slot,
41+
}
42+
}
43+
}
44+
3145
#[cfg_attr(feature = "frozen-abi", derive(AbiExample, AbiEnumVisitor))]
3246
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
3347
pub enum Vote {
@@ -221,6 +235,13 @@ impl CertificatePool {
221235
self.highest_finalized_slot
222236
}
223237

238+
pub fn is_finalized_slot(&self, slot: Slot) -> bool {
239+
self.certificates
240+
.get(&(slot, CertificateType::Finalize))
241+
.map(|certificate| certificate.is_complete())
242+
.unwrap_or(false)
243+
}
244+
224245
/// Determines if the leader can start based on notarization and skip certificates.
225246
pub fn make_start_leader_decision(
226247
&self,

0 commit comments

Comments
 (0)