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,
)
| 92 | /// |
| 93 | /// Vector of hashes up to and including the specified sequence. |
| 94 | pub 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 | /// |
no test coverage detected