Remove catch all pattern

The `PushBytes` type enforces len is less than 0x100000000 so we do
not need to panic in a catch all pattern after explicitly matching
against less than 0x100000000.

Refactor only because of the invariant on `PushBytes` - no logic
changes.
This commit is contained in:
Tobin C. Harding 2024-08-06 06:18:39 +10:00
parent c28d5d5964
commit 6836de9ee6
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 1 additions and 2 deletions

View File

@ -113,14 +113,13 @@ impl ScriptBuf {
self.0.push((n % 0x100) as u8);
self.0.push((n / 0x100) as u8);
}
n if n < 0x100000000 => {
n => { // `PushBytes` enforces len < 0x100000000
self.0.push(opcodes::Ordinary::OP_PUSHDATA4.to_u8());
self.0.push((n % 0x100) as u8);
self.0.push(((n / 0x100) % 0x100) as u8);
self.0.push(((n / 0x10000) % 0x100) as u8);
self.0.push((n / 0x1000000) as u8);
}
_ => panic!("tried to put a 4bn+ sized object into a script!"),
}
// Then push the raw bytes
self.0.extend_from_slice(data.as_bytes());