mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-29 04:05:21 +08:00
feat: new method find_epoch_by_id() for a list of epochs
This commit is contained in:
@@ -248,6 +248,18 @@ impl<L> StacksEpoch<L> {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Find an epoch by its ID
|
||||
/// Returns Some(index) if the epoch is in the list
|
||||
/// Returns None if not
|
||||
pub fn find_epoch_by_id(epochs: &[StacksEpoch<L>], epoch_id: StacksEpochId) -> Option<usize> {
|
||||
for (i, epoch) in epochs.iter().enumerate() {
|
||||
if epoch.epoch_id == epoch_id {
|
||||
return Some(i);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// StacksEpochs are ordered by start block height
|
||||
|
||||
Reference in New Issue
Block a user