Merge rust-bitcoin/rust-bitcoin#2930: Improve docs on private `Witness` fields
c717f7f424
Improve docs on private Witness fields (Tobin C. Harding) Pull request description: The `Witness` type is a reasonable complex data structure, make an effort to clarify its structure in the docs on the private fields. Private docs only. (Original idea pulled out of #2133.) ACKs for top commit: Kixunil: ACKc717f7f424
apoelstra: ACKc717f7f424
much clearer, thanks! Tree-SHA512: 9d54b7eeefec97e584fb5f275049dbac0473c949fae8ab05c6961d6fc424c17a058af7037c2220ef1446af294d78c68bfee741cfeca1b18ecc402935d8069dab
This commit is contained in:
commit
45e311cab9
|
@ -28,8 +28,12 @@ use crate::{Script, VarInt};
|
||||||
/// [segwit upgrade]: <https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki>
|
/// [segwit upgrade]: <https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki>
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Witness {
|
pub struct Witness {
|
||||||
/// Contains the witness `Vec<Vec<u8>>` serialization without the initial varint indicating the
|
/// Contains the witness `Vec<Vec<u8>>` serialization.
|
||||||
/// number of elements (which is stored in `witness_elements`).
|
///
|
||||||
|
/// Does not include the initial varint indicating the number of elements, instead this is
|
||||||
|
/// stored stored in `witness_elements`. Concatenated onto the end of `content` is the index
|
||||||
|
/// area, this is a `4 * witness_elements` bytes area which stores the index of the start of
|
||||||
|
/// each witness item.
|
||||||
content: Vec<u8>,
|
content: Vec<u8>,
|
||||||
|
|
||||||
/// The number of elements in the witness.
|
/// The number of elements in the witness.
|
||||||
|
@ -38,8 +42,10 @@ pub struct Witness {
|
||||||
/// like [`Witness::push`] don't have to shift the entire array.
|
/// like [`Witness::push`] don't have to shift the entire array.
|
||||||
witness_elements: usize,
|
witness_elements: usize,
|
||||||
|
|
||||||
/// This is the valid index pointing to the beginning of the index area. This area is 4 *
|
/// This is the valid index pointing to the beginning of the index area.
|
||||||
/// stack_size bytes at the end of the content vector which stores the indices of each item.
|
///
|
||||||
|
/// Said another way, this is the total length of all witness elements serialized (without the
|
||||||
|
/// element count but with their sizes serialized as compact size).
|
||||||
indices_start: usize,
|
indices_start: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue