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

Function find_change_sequence

atomic-repository/src/history/iter.rs:312–329  ·  view source on GitHub ↗

Find the sequence number for a change by its hash. # Arguments `txn` - Read transaction `view` - View to search `hash` - Hash of the change to find # Returns The sequence number if found, or None if the change is not in the view.

(
    txn: &T,
    view: &ViewState,
    hash: &Hash,
)

Source from the content-addressed store, hash-verified

310///
311/// The sequence number if found, or None if the change is not in the view.
312pub fn find_change_sequence<T: ViewTxnT>(
313 txn: &T,
314 view: &ViewState,
315 hash: &Hash,
316) -> HistoryResult<Option<u64>> {
317 // First get the internal ID
318 let node_id = match txn.get_internal(hash) {
319 Ok(Some(id)) => id,
320 Ok(None) => return Ok(None),
321 Err(e) => return Err(HistoryError::Database(e.to_string())),
322 };
323
324 // Then look up the sequence
325 match txn.get_change_seq(view, node_id) {
326 Ok(seq) => Ok(seq),
327 Err(e) => Err(HistoryError::Database(e.to_string())),
328 }
329}
330
331/// Check if a change is in the view's history.
332///

Callers 2

is_change_in_historyFunction · 0.70

Calls 2

get_internalMethod · 0.45
get_change_seqMethod · 0.45

Tested by

no test coverage detected