INNER CODE UNIT · Rust

overlay_dev_conf

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

fn overlay_dev_conf<S: Storage>(
    fs: &mut Fs<S>,
    incoming: &[u8],
    out: &mut [u8],
) -> Result<usize, DevConfError> {
    let mut stored = [0u8; EF_DEV_CONF_READ_MAX];
    // Three answers, not two. ABSENT (`Ok(None)`) merges onto nothing, so the
    // request becomes the record — a first write. UNPARSEABLE keeps only the whole
    // TLV prefix below, so the tail an older, laxer build wrote is replaced; that is
    // what the previous behaviour did for every input and is still right for bytes
    // no parser can attribute to a tag. FAULTED is neither: merging onto nothing
    // turns ykman's one-field delta into a REPLACEMENT that discards every other
    // setting the owner wrote, so refusing is the only answer that cannot lose data.
    let stored_n = match fs.try_read(EF_DEV_CONF, &mut stored) {
        Ok(n) => n.unwrap_or(0).min(EF_DEV_CONF_READ_MAX),
        Err(_) => return Err(DevConfError::Store),
    };
    let stored = &stored[..whole_tlvs(&stored[..stored_n])];

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…