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

Function effective_state

atomic-repository/src/repository/remote_cache.rs:417–430  ·  view source on GitHub ↗

The digest of `state`'s effective perspective: the view and each view in [`sandbox_view_chain`], by id, scope, own Merkle state and change count. The view's own Merkle state is not enough to fence a draft: a change landing on an ancestor moves what the draft sees without touching its own log. Every input here is a row a sandbox's cache holds verbatim (the skeleton carries the view and its ancesto

(
    txn: &atomic_core::pristine::ReadTxn,
    state: &atomic_core::pristine::ViewState,
)

Source from the content-addressed store, hash-verified

415/// skeleton carries the view and its ancestors as themselves), so the cache
416/// computes the same digest from its own pristine.
417fn effective_state(
418 txn: &atomic_core::pristine::ReadTxn,
419 state: &atomic_core::pristine::ViewState,
420) -> Result<Hash, RepositoryError> {
421 let mut bytes = b"atomic.sandbox.effective-view.v1".to_vec();
422 for view in std::iter::once(state.clone()).chain(sandbox_view_chain(txn, state)?) {
423 // Hash input only, never stored or sorted.
424 bytes.extend_from_slice(&view.id.to_le_bytes());
425 bytes.push(view.kind as u8);
426 bytes.extend_from_slice(view.state.as_bytes());
427 bytes.extend_from_slice(&view.change_count.to_le_bytes());
428 }
429 Ok(Hash::of(&bytes))
430}
431
432impl Repository {
433 /// The visible change ids of `view`, sorted.

Callers 2

Calls 5

sandbox_view_chainFunction · 0.85
to_le_bytesMethod · 0.80
cloneMethod · 0.45
pushMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected