(
&self,
view_a: &str,
view_b: &str,
)
| 203 | /// ``` |
| 204 | #[allow(clippy::type_complexity)] |
| 205 | pub fn diff_views( |
| 206 | &self, |
| 207 | view_a: &str, |
| 208 | view_b: &str, |
| 209 | ) -> Result<(Vec<Hash>, Vec<Hash>, Vec<Hash>), RepositoryError> { |
| 210 | let txn = self |
| 211 | .pristine |
| 212 | .read_txn() |
| 213 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 214 | |
| 215 | let a = txn |
| 216 | .get_view(view_a) |
| 217 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 218 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 219 | name: view_a.to_string(), |
| 220 | })?; |
| 221 | |
| 222 | let b = txn |
| 223 | .get_view(view_b) |
| 224 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 225 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 226 | name: view_b.to_string(), |
| 227 | })?; |
| 228 | |
| 229 | // Collect hashes from each view |
| 230 | let a_changes: Vec<Hash> = { |
| 231 | let iter = txn |
| 232 | .iter_changes(&a, 0) |
| 233 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 234 | let mut hashes = Vec::new(); |
| 235 | for result in iter { |
| 236 | let (_seq, node_id, _merkle) = |
| 237 | result.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 238 | if let Some(hash) = txn |
| 239 | .get_external(node_id) |
| 240 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 241 | { |
| 242 | hashes.push(hash); |
| 243 | } |
| 244 | } |
| 245 | hashes |
| 246 | }; |
| 247 | |
| 248 | let b_changes: Vec<Hash> = { |
| 249 | let iter = txn |
| 250 | .iter_changes(&b, 0) |
| 251 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 252 | let mut hashes = Vec::new(); |
| 253 | for result in iter { |
| 254 | let (_seq, node_id, _merkle) = |
| 255 | result.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 256 | if let Some(hash) = txn |
| 257 | .get_external(node_id) |
| 258 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 259 | { |
| 260 | hashes.push(hash); |
| 261 | } |
| 262 | } |
no test coverage detected