Skip to content

Commit ff923c1

Browse files
committed
Only deliver blocks once per round.
1 parent 710d7cd commit ff923c1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test-utils/src/binaries/block-maker.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ impl ForwardApi for Service {
6969
let list = r.into_inner();
7070
let round = RoundNumber::from(list.round);
7171
let bytes = Bytes::from(list.encode_to_vec());
72+
let mut is_new = false;
7273
let (prev, bnum) = self
7374
.cache
7475
.get_or_insert_with(&round, || -> Result<_, Infallible> {
76+
is_new = true;
7577
Ok((
7678
bytes.clone(),
7779
self.next_block.fetch_add(1, Ordering::Relaxed),
@@ -82,13 +84,15 @@ impl ForwardApi for Service {
8284
error!(%round, "inclusion list mismatch");
8385
exit(1)
8486
}
85-
let block = Block {
86-
number: bnum,
87-
round: list.round,
88-
payload: bytes,
89-
};
90-
if let Err(err) = self.output.send(block) {
91-
return Err(Status::internal(err.to_string()));
87+
if is_new {
88+
let block = Block {
89+
number: bnum,
90+
round: list.round,
91+
payload: bytes,
92+
};
93+
if let Err(err) = self.output.send(block) {
94+
return Err(Status::internal(err.to_string()));
95+
}
9296
}
9397
Ok(Response::new(()))
9498
}

0 commit comments

Comments
 (0)