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

Function get_changes_up_to_seq

atomic-repository/src/apply/queries.rs:94–123  ·  view source on GitHub ↗

Get changes up to a specific sequence number. # Arguments `txn` - Read transaction `view` - The view to query `max_sequence` - Maximum sequence (inclusive) # Returns Vector of hashes up to and including the specified sequence.

(
    txn: &T,
    view: &ViewState,
    max_sequence: u64,
)

Source from the content-addressed store, hash-verified

92///
93/// Vector of hashes up to and including the specified sequence.
94pub fn get_changes_up_to_seq<T: ViewTxnT>(
95 txn: &T,
96 view: &ViewState,
97 max_sequence: u64,
98) -> InsertResult<Vec<Hash>> {
99 let mut changes = Vec::new();
100
101 let iter = txn
102 .iter_changes(view, 0)
103 .map_err(|e| InsertError::Database(e.to_string()))?;
104
105 for result in iter {
106 let (seq, node_id, _merkle) = result.map_err(|e| InsertError::Database(e.to_string()))?;
107
108 if seq > max_sequence {
109 break;
110 }
111
112 let hash = txn
113 .get_external(node_id)
114 .map_err(|e| InsertError::Database(e.to_string()))?
115 .ok_or_else(|| {
116 InsertError::Internal(format!("Change {} has no external hash", node_id.0))
117 })?;
118
119 changes.push(hash);
120 }
121
122 Ok(changes)
123}
124
125/// Find which changes from a list are missing in a view.
126///

Callers 1

get_changes_up_to_tagMethod · 0.85

Calls 3

iter_changesMethod · 0.45
get_externalMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected