MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / mint_view_snapshot

Function mint_view_snapshot

atomic-cli/src/commands/push/command.rs:87–112  ·  view source on GitHub ↗

Mint the content-addressed `ViewSnapshot` for a view from its local manifest and the remote's current snapshot key (`prev`, for the CAS-on-`prev` chain). The `own_set_id` fold matches the server's `from_manifest` bridge exactly, so client and server mint byte-identical objects with identical content keys.

(manifest: &ViewManifest, prev: Option<String>)

Source from the content-addressed store, hash-verified

85/// The `own_set_id` fold matches the server's `from_manifest` bridge exactly, so
86/// client and server mint byte-identical objects with identical content keys.
87fn mint_view_snapshot(manifest: &ViewManifest, prev: Option<String>) -> ViewSnapshot {
88 let own_changes: Vec<String> = manifest.changes.iter().map(|h| h.to_base32()).collect();
89 let mut acc = SetId::ZERO;
90 for h in &manifest.changes {
91 acc = acc.add(h);
92 }
93 let own_set_id = acc.to_base32();
94 let merkle_state = if manifest.changes.is_empty() {
95 None
96 } else {
97 Some(manifest.state.to_base32())
98 };
99 let scope = if manifest.scope.is_draft() {
100 ViewScopeLabel::Draft
101 } else {
102 ViewScopeLabel::Shared
103 };
104 ViewSnapshot::new(
105 scope,
106 manifest.parent.clone(),
107 prev.into_iter().collect(),
108 own_changes,
109 own_set_id,
110 merkle_state,
111 )
112}
113
114// Constants
115

Callers 1

run_asyncMethod · 0.85

Calls 7

iterMethod · 0.45
to_base32Method · 0.45
addMethod · 0.45
is_emptyMethod · 0.45
is_draftMethod · 0.45
cloneMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected