Skip to content

Commit ae0c3a8

Browse files
author
yeastplume
committed
Update to reading/writing order as found by test
1 parent eae7269 commit ae0c3a8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

core/src/core/pmmr/segment.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
//! Segment of a PMMR.
1616
17-
use crate::core::hash::{Hash, Hashed};
18-
use crate::core::pmmr::{self, Backend, ReadablePMMR, ReadonlyPMMR};
19-
use crate::core::BlockHeader;
17+
use crate::core::hash::Hash;
18+
use crate::core::pmmr;
19+
use crate::core::pmmr::{Backend, ReadablePMMR, ReadonlyPMMR};
2020
use crate::ser::{
21-
self, Error as SerError, PMMRIndexHashable, PMMRable, Readable, Reader, Writeable, Writer,
21+
Error as SerError, PMMRIndexHashable, PMMRable, Readable, Reader, Writeable, Writer,
2222
};
2323
use croaring::Bitmap;
2424
use log::error;
@@ -602,6 +602,12 @@ impl<T: Readable> Readable for Segment<T> {
602602
hash_pos.push(pos - 1);
603603
}
604604

605+
let mut hashes = Vec::<Hash>::with_capacity(n_hashes);
606+
for _ in 0..n_hashes {
607+
let hash: Hash = Readable::read(reader)?;
608+
hashes.push(hash);
609+
}
610+
605611
let n_leaves = reader.read_u64()? as usize;
606612
// Also check leaves count for safety
607613
if n_leaves > MAX_LEAVES_PER_SEGMENT {
@@ -623,12 +629,6 @@ impl<T: Readable> Readable for Segment<T> {
623629
leaf_pos.push(pos - 1);
624630
}
625631

626-
let mut hashes = Vec::<Hash>::with_capacity(n_hashes);
627-
for _ in 0..n_hashes {
628-
let hash: Hash = Readable::read(reader)?;
629-
hashes.push(hash);
630-
}
631-
632632
let mut leaf_data = Vec::<T>::with_capacity(n_leaves);
633633
for _ in 0..n_leaves {
634634
leaf_data.push(Readable::read(reader)?);

0 commit comments

Comments
 (0)