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

Function mint_view_snapshot

atomic-cli/src/commands/push/command.rs:89–114  ·  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

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

Callers 1

run_asyncMethod · 0.70

Calls 8

collectMethod · 0.45
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