consensus_encoding: Remove private const
What changed, and why it matters
This commit replaces a named constant with the number 9 in one place. It is a straightforward code cleanup with no security relevance. The value 9 is the well-known maximum byte length of a Bitcoin compact-size integer encoding, and the change is functionally identical.
No security action needed. This is a normal refactoring/cleanup change. Optionally, restore use of compact_size::MAX_ENCODING_SIZE once the internals crate version exposing it is released, to avoid magic numbers.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In consensus_encoding/src/encode/encoders.rs, the private constant SIZE is now defined as the literal 9 instead of compact_size::MAX_ENCODING_SIZE. The commit message explains that the internals crate change exposing compact_size::MAX_ENCODING_SIZE has not been released yet, so the project temporarily inlines the magic number. The semantics are unchanged: Bitcoin compact-size integers are at most 9 bytes (1 marker byte plus up to 8 value bytes).
Changed components
consensus_encoding/src/encode/encoders.rsInspect captured patch +1 / −1
diff --git a/consensus_encoding/src/encode/encoders.rs b/consensus_encoding/src/encode/encoders.rs
index 691bffb1..f5d2de1f 100644
--- a/consensus_encoding/src/encode/encoders.rs
+++ b/consensus_encoding/src/encode/encoders.rs
@@ -17,7 +17,7 @@ use internals::{compact_size, ToU64};
use super::{Encodable, Encoder};
/// The maximum length of a compact size encoding.
-const SIZE: usize = compact_size::MAX_ENCODING_SIZE;
+const SIZE: usize = 9;
/// An encoder for a single byte slice.
pub struct BytesEncoder<'sl> {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.