Skip to content

Commit e4f195b

Browse files
Provide size for content ballot map
1 parent d45601d commit e4f195b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rust/catalyst-contest/src/contest_ballot.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ impl Encode<()> for ContentBallot {
3636
e: &mut Encoder<W>,
3737
ctx: &mut (),
3838
) -> Result<(), minicbor::encode::Error<W::Error>> {
39-
e.begin_map()?;
39+
let len = self.choices.len() as u64
40+
+ self.column_proof.is_some() as u64
41+
+ self.matrix_proof.is_some() as u64
42+
+ self.voter_choices.is_some() as u64;
43+
e.map(len)?;
4044

4145
for (&key, val) in self.choices.iter() {
4246
e.u64(key)?.encode(val)?;
@@ -51,7 +55,6 @@ impl Encode<()> for ContentBallot {
5155
e.str("voter-choices")?.encode(voter_choices)?;
5256
}
5357

54-
e.end()?;
5558
Ok(())
5659
}
5760
}

0 commit comments

Comments
 (0)