MCPcopy Create free account
hub / github.com/argumentcomputer/ix / get_anon

Method get_anon

crates/ixon/src/serialize.rs:1658–1787  ·  view source on GitHub ↗

Anonymous-only deserialization: read the header + blobs + consts sections, parse-and-discard the metadata sections (names / named / comms). Returns an `Env` with populated `consts` (lazy) and `blobs`, and empty** `named` / `names` / `comms`. The merkle-root header is re-verified against the recomputed root over `consts.keys()`, exactly as in [`Env::get`]. Why "parse and discard"? Sections 3-5 la

(buf: &mut &[u8])

Source from the content-addressed store, hash-verified

1656 // Section 2: Consts (Address -> Constant)
1657 //
1658 // Reuses the already-collected+sorted `const_addrs` from the merkle
1659 // root computation above.
1660 // ─────────────────────────────────────────────────────────────────────
1661 let sec_start = std::time::Instant::now();
1662 if verbose {
1663 eprintln!("[Env::put] section 2/6 consts: {} entries", self.consts.len(),);
1664 }
1665 if verbose {
1666 eprintln!(
1667 "[Env::put] section 2/6 consts: collected+sorted in {:.1}s, \
1668 streaming put...",
1669 sec_start.elapsed().as_secs_f64(),
1670 );
1671 }
1672 let put_start = std::time::Instant::now();
1673 put_u64(const_addrs.len() as u64, buf);
1674 for addr in &const_addrs {
1675 if let Some(entry) = self.consts.get(addr) {
1676 put_address(addr, buf);
1677 // Length-prefix sidecar (Tag0) so lazy loaders can slice each
1678 // constant without parsing its Tag4 envelope. The length is
1679 // NOT part of the content-addressed bytes — `Address::hash` is
1680 // computed only over `raw_bytes()`.
1681 let bytes = entry.value().raw_bytes();
1682 Tag0::new(bytes.len() as u64).put(buf);
1683 buf.extend_from_slice(bytes);
1684 }
1685 }
1686 if verbose {
1687 eprintln!(
1688 "[Env::put] section 2/6 consts done: put in {:.1}s, total {:.1}s \
1689 ({} bytes so far)",
1690 put_start.elapsed().as_secs_f64(),
1691 sec_start.elapsed().as_secs_f64(),
1692 buf.len(),
1693 );
1694 }
1695
1696 // ─────────────────────────────────────────────────────────────────────
1697 // Section 3: anon_hints (§2 index -> ReducibilityHints)
1698 //
1699 // The canonical hint channel, placed before the metadata sections
1700 // so `get_anon`/`get_anon_mmap` can stop right after it (they
1701 // never touch names/named/comms). `anon_hints` is the single home
1702 // for hints: the compiler registers them per constant address
1703 // (`Env::register_hint`) and readers fill the map from this very
1704 // section. Hints are performance-only advice and intentionally
1705 // NOT covered by the consts merkle root.
1706 //
1707 // Entries are keyed by rank in §2's ascending-address order,
1708 // delta-coded against the previous entry (the address sort below
1709 // is load-bearing: it makes the ranks strictly ascending), with
1710 // the hint fused into one Tag0 value — 2-3 bytes per entry
1711 // instead of a redundant 32-byte address.
1712 // ─────────────────────────────────────────────────────────────────────
1713 let sec_start = std::time::Instant::now();
1714 let mut hint_pairs: Vec<(Address, ReducibilityHints)> =
1715 self.anon_hints.iter().map(|e| (e.key().clone(), *e.value())).collect();

Callers

nothing calls this directly

Calls 14

from_bytesFunction · 0.85
get_name_componentFunction · 0.85
get_named_indexedFunction · 0.85
read_anon_hints_sectionFunction · 0.85
merkle_root_canonicalFunction · 0.85
get_hashMethod · 0.80
pushMethod · 0.80
keyMethod · 0.80
get_addressFunction · 0.70
get_u64Function · 0.70
lenMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected