Export a view's complete identity as a [`ViewManifest`]. The manifest carries the view's change log **exactly as stored** in `VIEW_CHANGES` (for a draft this includes the inherited prefix copied at fork time), plus scope, parent name, and the view's merkle state. The exported manifest is verified before it is returned, so a corrupted log surfaces here rather than on the receiving end.
(&self, name: &str)
| 724 | /// The exported manifest is verified before it is returned, so a |
| 725 | /// corrupted log surfaces here rather than on the receiving end. |
| 726 | pub fn view_manifest(&self, name: &str) -> Result<ViewManifest, RepositoryError> { |
| 727 | let txn = self |
| 728 | .pristine |
| 729 | .read_txn() |
| 730 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 731 | |
| 732 | let view = txn |
| 733 | .get_view(name) |
| 734 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 735 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 736 | name: name.to_string(), |
| 737 | })?; |
| 738 | |
| 739 | let parent = match view.parent { |
| 740 | Some(parent_id) => txn |
| 741 | .get_view_by_id(parent_id) |
| 742 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 743 | .map(|p| p.name), |
| 744 | None => None, |
| 745 | }; |
| 746 | |
| 747 | let mut changes = Vec::with_capacity(view.change_count as usize); |
| 748 | for item in txn |
| 749 | .iter_changes(&view, 0) |
| 750 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 751 | { |
| 752 | let (_seq, node_id, _merkle) = |
| 753 | item.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 754 | let hash = txn |
| 755 | .get_external(node_id) |
| 756 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 757 | .ok_or_else(|| { |
| 758 | RepositoryError::Database(format!( |
| 759 | "change {} in view '{}' has no external hash", |
| 760 | node_id.0, name |
| 761 | )) |
| 762 | })?; |
| 763 | changes.push(hash); |
| 764 | } |
| 765 | |
| 766 | let manifest = ViewManifest { |
| 767 | name: view.name.clone(), |
| 768 | scope: view.kind, |
| 769 | parent, |
| 770 | changes, |
| 771 | state: view.state, |
| 772 | }; |
| 773 | manifest.verify()?; |
| 774 | Ok(manifest) |
| 775 | } |
| 776 | |
| 777 | /// Reconcile a view manifest by **set union** over the common causal graph. |
| 778 | /// |