INNER CODE UNIT · Rust

stored_matches

TheMaxMur/RS-Key · crates/rsk-devconf/src/lib.rs:346

fn stored_matches<S: Storage>(fs: &mut Fs<S>, want: &[u8]) -> bool {
    let mut cur = [0u8; EF_DEV_CONF_READ_MAX];
    // `read` reports the value's *full* stored length, which an over-length record
    // from an older build can push past `cur` — compare only when it fits.
    matches!(fs.read(EF_DEV_CONF, &mut cur),
        Some(c) if c == want.len() && c <= cur.len() && cur[..c] == *want)
}

/// Overlay the TLV entries `incoming` carries onto the stored `EF_DEV_CONF`,
/// writing the result into `out` and returning its length.
///
/// A DeviceConfig write is a *delta*: real hardware merges it, and every ykman
/// command that touches one field sends that field alone. Replacing the record
/// wholesale therefore discards every setting the request did not mention.
/// Entries the request repeats win; the rest are kept in their stored order, so a
/// no-op write is byte-stable and `dev_conf_unchanged` still short-circuits it.
fn overlay_dev_conf<S: Storage>(
    fs: &mut Fs<S>,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…