Skip to content

Commit

Permalink
fix: Add range check to signature index (#5157)
Browse files Browse the repository at this point in the history
Signed-off-by: Sam H. Smith <sam.henning.smith@protonmail.com>
  • Loading branch information
SamHSmith authored Oct 22, 2024
1 parent de7181c commit ae5eb8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion crates/iroha_core/src/sumeragi/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,19 @@ impl Sumeragi {
);

if let Ok(signatory_idx) = usize::try_from(signature.0) {
let signatory = &self.topology.as_ref()[signatory_idx];
let signatory = if let Some(s) = self.topology.as_ref().get(signatory_idx) {
s
} else {
error!(
peer_id=%self.peer_id,
role=%self.role(),
?signatory_idx,
topology_size=%self.topology.as_ref().len(),
"Unknown signatory"
);

return;
};

match self.topology.role(signatory) {
Role::Leader => error!(
Expand Down
2 changes: 1 addition & 1 deletion crates/iroha_p2p/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {
#[log(skip(self, shutdown_signal), fields(listen_addr=%self.listen_addr, public_key=%self.key_pair.public_key()))]
async fn run(mut self, shutdown_signal: ShutdownSignal) {
// TODO: probably should be configuration parameter
let mut update_topology_interval = tokio::time::interval(Duration::from_millis(100));
let mut update_topology_interval = tokio::time::interval(Duration::from_millis(1000));
loop {
tokio::select! {
// Select is biased because we want to service messages to take priority over data messages.
Expand Down

0 comments on commit ae5eb8a

Please sign in to comment.