Add more rustdocs to WitnessProgram

Add rustdocs to `WitnessProgram` commenting on why we carry the witness
version number around with the witness program. This is mainly a dev
comment but it helps document the invariants so make it a rustdoc
comment.
This commit is contained in:
Tobin C. Harding 2023-07-13 09:53:33 +10:00
parent 89303c1464
commit 552f19abe3
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 5 additions and 1 deletions

View File

@ -14,9 +14,13 @@ use crate::blockdata::script::witness_version::WitnessVersion;
use crate::blockdata::script::{PushBytes, PushBytesBuf, PushBytesErrorReport}; use crate::blockdata::script::{PushBytes, PushBytesBuf, PushBytesErrorReport};
/// The segregated witness program. /// The segregated witness program.
///
/// The segregated witness program is technically only the program bytes _excluding_ the witness
/// version, however we maintain length invariants on the `program` that are governed by the version
/// number, therefore we carry the version number around along with the program bytes.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct WitnessProgram { pub struct WitnessProgram {
/// The witness program version number. /// The segwit version associated with this witness program.
version: WitnessVersion, version: WitnessVersion,
/// The witness program (between 2 and 40 bytes). /// The witness program (between 2 and 40 bytes).
program: PushBytesBuf, program: PushBytesBuf,