feat(bls): boot counting (#107)

* feat(bls): parse and render boot counters

* feat(bls): sort entries with no boot tries left last

* feat(boot): strip boot counters from bls entry ids

* feat(boot): consume bls boot counter tries before booting

* fix(boot): never default to a bad boot counter entry while a good one exists
This commit is contained in:
alex authored and GitHub committed 2026-10-03 17:19:27 -07:00
1 parent 5e8fe7c783
commit 1207f1d4e9
5 files changed
+398 -7

No files matched your search

+20
View File
@@ -1,3 +1,4 @@
use crate::boot_counter::BootCounterTarget;
use crate::context::SproutContext;
use alloc::rc::Rc;
use alloc::string::{String, ToString};
@@ -14,6 +15,7 @@ pub struct BootableEntry {
default: bool,
pin_name: bool,
sort_key: Option<String>,
boot_counter: Option<BootCounterTarget>,
}
impl BootableEntry {
@@ -32,6 +34,7 @@ impl BootableEntry {
default: false,
pin_name: false,
sort_key: None,
boot_counter: None,
}
}
@@ -100,6 +103,23 @@ impl BootableEntry {
self.pin_name = true;
}
/// Record where the boot counter of this entry is stored.
pub fn set_boot_counter(&mut self, target: BootCounterTarget) {
self.boot_counter = Some(target);
}
/// Fetch where the boot counter of this entry is stored, if it has one.
pub fn boot_counter(&self) -> Option<&BootCounterTarget> {
self.boot_counter.as_ref()
}
/// Fetch whether the entry has a boot counter with no tries left.
pub fn is_bad(&self) -> bool {
self.boot_counter
.as_ref()
.is_some_and(|target| target.counter.is_bad())
}
/// Prepend the name of the entry with `prefix`.
pub fn prepend_name_prefix(&mut self, prefix: &str) {
self.name.insert_str(0, prefix);