(children: &[Option<Pointer>], out: &mut dyn BufMut)
| 659 | |
| 660 | #[inline] |
| 661 | pub fn encode_branch(children: &[Option<Pointer>], out: &mut dyn BufMut) -> usize { |
| 662 | // first encode the header |
| 663 | let mut payload_length = 1; |
| 664 | for child in children.iter() { |
| 665 | if let Some(child) = child { |
| 666 | payload_length += child.rlp().len(); |
| 667 | } else { |
| 668 | payload_length += 1; |
| 669 | } |
| 670 | } |
| 671 | Header { list: true, payload_length }.encode(out); |
| 672 | // now encode the children |
| 673 | for child in children.iter() { |
| 674 | if let Some(child) = child { |
| 675 | out.put_slice(child.rlp()); |
| 676 | } else { |
| 677 | out.put_u8(EMPTY_STRING_CODE); |
| 678 | } |
| 679 | } |
| 680 | // and encode the empty 17th slot |
| 681 | out.put_u8(EMPTY_STRING_CODE); |
| 682 | |
| 683 | payload_length + length_of_length(payload_length) |
| 684 | } |
| 685 | |
| 686 | fn arb_children() -> impl Strategy<Value = [Option<Pointer>; 16]> { |
| 687 | (proptest::collection::vec(arbitrary::any::<Pointer>(), 2..16), 1..15).prop_map( |
no test coverage detected