refactor: simplify recording MerkleStore structure

This commit is contained in:
Bobbin Threadbare
2023-06-23 23:07:24 -07:00
parent 679a30e02e
commit f08644e4df
8 changed files with 348 additions and 364 deletions

36
src/utils/mod.rs Normal file
View File

@@ -0,0 +1,36 @@
use super::{utils::string::String, Word};
use core::fmt::{self, Write};
#[cfg(not(feature = "std"))]
pub use alloc::format;
#[cfg(feature = "std")]
pub use std::format;
mod kv_map;
// RE-EXPORTS
// ================================================================================================
pub use winter_utils::{
string, uninit_vector, Box, ByteReader, ByteWriter, Deserializable, DeserializationError,
Serializable, SliceReader,
};
pub mod collections {
pub use super::kv_map::*;
pub use winter_utils::collections::*;
}
// UTILITY FUNCTIONS
// ================================================================================================
/// Converts a [Word] into hex.
pub fn word_to_hex(w: &Word) -> Result<String, fmt::Error> {
let mut s = String::new();
for byte in w.iter().flat_map(|e| e.to_bytes()) {
write!(s, "{byte:02x}")?;
}
Ok(s)
}