From c44608f59feb080063a3707b78dff5a48bbbf59a Mon Sep 17 00:00:00 2001 From: Kriday Dave Date: Mon, 5 Oct 2026 15:35:20 +0530 Subject: [PATCH] docs: drop comments that restate the code Comment-only. No code line changes. - engine.rs: four inline comments restating the serde_json round-trip that the two lines below them already say. One doc line kept because it records why the order matters (the hash covers this form). - keys.rs add_to_index: a trailing question to yourself about rotation. The next line is keys.push, and the code below it pushes. - mount.rs: an empty 'Public mount helper' banner above the FUSE impl with no helper under it. - cli.rs: '// Handlers' had lost its opening rule; 'Validate has_breaking helper stays consistent' narrates the debug_assert on the next line. 4 insertions, 12 deletions. --- src/cli.rs | 3 ++- src/engine.rs | 8 ++------ src/keys.rs | 1 - src/mount.rs | 4 ---- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 62ae7fc..05469ab 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -562,6 +562,8 @@ fn print_status_line(ok: bool) { fn print_unsigned_warning() { println!("warning: ⚠ UNSIGNED — hash ok, not cryptographically signed"); } + +// --------------------------------------------------------------------------- // Handlers // --------------------------------------------------------------------------- @@ -1843,7 +1845,6 @@ pub fn handle_check(args: CheckArgs) -> Result<(), TaprootError> { warning: warnings, }); } - // Validate has_breaking helper stays consistent debug_assert_eq!(has_breaking(&diffs), breaking > 0); Ok(()) diff --git a/src/engine.rs b/src/engine.rs index 0d03682..9c66857 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -9,14 +9,10 @@ use crate::state::{SignedState, TaprootState}; pub struct StateEngine; impl StateEngine { - /// Canonical JSON — sorted keys, no whitespace tricks. - /// Uses serde_json with BTreeMap already sorted, then re-serializes deterministically. + /// Canonical JSON — sorted keys, no whitespace tricks. The hash is taken over + /// this form, so key order must be stable across struct and map nesting. pub fn to_canonical_json(state: &TaprootState) -> Result, TaprootError> { - // serde_json sorts struct keys by definition order; BTreeMap sorts env_vars. - // For true canonical, we serialize via Value then to_string with sorted keys. let json = serde_json::to_string(state)?; - // Parse and re-stringify to ensure deterministic key ordering at all levels. - // serde_json's Value uses BTreeMap internally when `preserve_order` is off (default). let value: serde_json::Value = serde_json::from_str(&json)?; Ok(serde_json::to_vec(&value)?) } diff --git a/src/keys.rs b/src/keys.rs index 8db71e5..02f73c5 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -123,7 +123,6 @@ impl KeyStore { fn add_to_index(&self, kp: &Keypair) -> Result<(), TaprootError> { let mut keys = self.load_index()?; - // deactivate previous active keys if this one is active? keep all active for rotation keys.push(kp.clone()); self.save_index(&keys)?; Ok(()) diff --git a/src/mount.rs b/src/mount.rs index c3f51d1..2587f10 100644 --- a/src/mount.rs +++ b/src/mount.rs @@ -706,10 +706,6 @@ impl Filesystem for TaprootFS { } } -// --------------------------------------------------------------------------- -// Public mount helper -// --------------------------------------------------------------------------- - // --------------------------------------------------------------------------- // Drift extraction // ---------------------------------------------------------------------------