diff --git a/checkpoint/src/builder.rs b/checkpoint/src/builder.rs index 51d9da1..e533851 100644 --- a/checkpoint/src/builder.rs +++ b/checkpoint/src/builder.rs @@ -85,7 +85,7 @@ fn main() -> anyhow::Result<()> { eprintln!("SHA-256: {}", hex::encode(digest)); if let Some(path) = args.integrity_out.as_deref() { - spaces_checkpoint::write_integrity(path, height, &block_hash, &digest)?; + spaces_checkpoint::write_integrity_to(path, height, &block_hash, &digest)?; eprintln!("Updated {}", path.display()); } diff --git a/checkpoint/src/lib.rs b/checkpoint/src/lib.rs index c8fdd2c..725c982 100644 --- a/checkpoint/src/lib.rs +++ b/checkpoint/src/lib.rs @@ -302,9 +302,21 @@ pub fn checkpoint() -> super::Checkpoint {{ ) } +/// Write the checkpoint constant to `checkpoint/src/integrity.rs` relative to +/// the current working directory. Must be run from the workspace root. +#[cfg(feature = "cli")] +pub fn write_integrity(height: u32, block_hash: &str, digest: &[u8; 32]) -> anyhow::Result<()> { + write_integrity_to( + Path::new("checkpoint/src/integrity.rs"), + height, + block_hash, + digest, + ) +} + /// Write the checkpoint constant to a Rust source file at `path`. #[cfg(feature = "cli")] -pub fn write_integrity( +pub fn write_integrity_to( path: &Path, height: u32, block_hash: &str,