Migrate BlockRc and BlockResyncManager to TypedTree

This commit is contained in:
Arthur Carcano
2026-06-10 17:10:29 +02:00
committed by Alex
parent eb91f463f5
commit 5a4da29f92
7 changed files with 186 additions and 113 deletions
+15
View File
@@ -155,6 +155,21 @@ pub fn gen_uuid() -> Uuid {
rand::rng().random::<[u8; 32]>().into()
}
impl garage_db::DbBytes for FixedBytes32 {
fn encode(&self) -> Vec<u8> {
self.0.into()
}
fn decode(bytes: &[u8]) -> std::result::Result<Self, garage_db::DecodeError> {
Self::try_from(bytes).ok_or_else(|| {
garage_db::DecodeError(
format!("invalid hash: expected 32 bytes, got {}", bytes.len()).into(),
)
})
}
}
impl garage_db::DbOrdKey for FixedBytes32 {}
#[cfg(test)]
mod test {
use super::*;
+12
View File
@@ -79,6 +79,18 @@ impl Error {
}
}
impl From<garage_db::DbError> for Error {
fn from(e: garage_db::DbError) -> Error {
Error::Db(e.into())
}
}
impl From<garage_db::DecodeError> for Error {
fn from(e: garage_db::DecodeError) -> Error {
Error::Db(e.into())
}
}
impl From<garage_db::TxError<Error>> for Error {
fn from(e: garage_db::TxError<Error>) -> Error {
match e {