Skip to content

Commit

Permalink
Merge pull request #61 from halseth/usize-64-bit-le
Browse files Browse the repository at this point in the history
[bug fix] write roots len as 64-representation always
  • Loading branch information
Davidson-Souza authored Jan 15, 2025
2 parents 1ee240f + 8a485ef commit 08d8be1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/accumulator/mem_forest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<Hash: AccumulatorHash> MemForest<Hash> {
/// ```
pub fn serialize<W: Write>(&self, mut writer: W) -> std::io::Result<()> {
writer.write_all(&self.leaves.to_le_bytes())?;
writer.write_all(&self.roots.len().to_le_bytes())?;
writer.write_all(&(self.roots.len() as u64).to_le_bytes())?;

for root in &self.roots {
root.write_one(&mut writer).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/accumulator/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,12 @@ impl<Hash: AccumulatorHash> Proof<Hash> {
/// ```
pub fn serialize<W: Write>(&self, mut writer: W) -> std::io::Result<usize> {
let mut len = 16;
writer.write_all(&self.targets.len().to_le_bytes())?;
writer.write_all(&(self.targets.len() as u64).to_le_bytes())?;
for target in &self.targets {
len += 8;
writer.write_all(&target.to_le_bytes())?;
}
writer.write_all(&self.hashes.len().to_le_bytes())?;
writer.write_all(&(self.hashes.len() as u64).to_le_bytes())?;
for hash in &self.hashes {
len += 32;
hash.write(&mut writer)?;
Expand Down
2 changes: 1 addition & 1 deletion src/accumulator/stump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Stump {
pub fn serialize<Dst: Write>(&self, mut writer: &mut Dst) -> std::io::Result<usize> {
let mut len = 8;
writer.write_all(&self.leaves.to_le_bytes())?;
writer.write_all(&self.roots.len().to_le_bytes())?;
writer.write_all(&(self.roots.len() as u64).to_le_bytes())?;
for root in self.roots.iter() {
len += 32;
root.write(&mut writer)?;
Expand Down

0 comments on commit 08d8be1

Please sign in to comment.