Skip to content

Commit 311608f

Browse files
committed
nit: uncontroversial improvement
1 parent f17a250 commit 311608f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

timeboost-sequencer/src/decrypt.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl Worker {
472472
msg = self.net.receive() => match msg {
473473
Ok((src, data)) => {
474474
match self.on_inbound(src, data).await {
475-
Ok(update) => cache_modified |= update,
475+
Ok(updated) => cache_modified |= updated,
476476
Err(DecrypterError::End(end)) => return end,
477477
Err(err) => warn!(node = %self.label, %err, %src, "error on message")
478478
}
@@ -549,7 +549,7 @@ impl Worker {
549549
/// A message from another node has been received.
550550
/// Returns true if decryption shares have been updated.
551551
async fn on_inbound(&mut self, src: PublicKey, bytes: Bytes) -> Result<bool> {
552-
trace!(node = %src, buf = %bytes.len(), "inbound message");
552+
trace!(node = %self.label, from = %src, buf = %bytes.len(), "inbound message");
553553
// ignore msg sent to self during broadcast
554554
if src == self.label {
555555
return Ok(false);
@@ -578,7 +578,7 @@ impl Worker {
578578
));
579579
}
580580

581-
let Some(committee) = self.committees.get(committee_id).cloned() else {
581+
let Some(committee) = self.committees.get(committee_id) else {
582582
return Err(DecrypterError::NoCommittee(committee_id));
583583
};
584584

@@ -622,7 +622,7 @@ impl Worker {
622622
return Ok(());
623623
};
624624

625-
let Some(committee) = self.committees.get(committee_id).cloned() else {
625+
let Some(committee) = self.committees.get(committee_id) else {
626626
return Err(DecrypterError::NoCommittee(committee_id));
627627
};
628628
committee
@@ -700,10 +700,7 @@ impl Worker {
700700
return Ok(());
701701
};
702702

703-
if round <= self.last_hatched_round || round < self.oldest_cached_round() {
704-
// shares for which the ciphertexts have already hatched
705-
// or shares that are older than the first ciphertext in
706-
// the local cache are not inserted.
703+
if round <= self.last_hatched_round {
707704
return Ok(());
708705
}
709706
trace!(node = %self.label, from=%src, %round, "inserting decrypted shares");
@@ -734,14 +731,15 @@ impl Worker {
734731

735732
async fn on_dkg_request(&mut self, bundle: DkgBundle) -> Result<()> {
736733
let cid = bundle.committee_id();
737-
if self.is_dkg_completed(bundle.committee_id()) {
734+
if self.is_dkg_completed(cid) {
738735
trace!(
739736
node = %self.label,
740737
committee_id = %cid,
741738
"received bundle but dkg already completed"
742739
);
743740
return Ok(());
744741
}
742+
745743
let stores = self.dkg_stores.read();
746744
let Some(dkg_store) = stores.iter().find(|s| s.committee().id() == *cid) else {
747745
return Err(DecrypterError::Internal(format!(
@@ -753,13 +751,14 @@ impl Worker {
753751
.dkg_tracker
754752
.entry(*cid)
755753
.or_insert_with(|| DkgAccumulator::new(dkg_store.to_owned()));
754+
drop(stores);
756755

757756
acc.try_add(bundle)
758757
.map_err(|e| DecrypterError::Dkg(format!("unable to add dkg bundle: {e}")))?;
759758

760759
if let Some(subset) = acc.try_finalize() {
761760
if *subset.committe_id() == self.current {
762-
let committee = dkg_store.committee();
761+
let committee = acc.committee();
763762
// TODO:(alex) centralize these constant, redeclared in DkgAccumulator.try_add()
764763
let aad: &[u8; 3] = b"dkg";
765764
let vess = ShoupVess::new_fast_from(committee);

0 commit comments

Comments
 (0)