From c72f00a984e0f53d842b0b378a7a9f19580042f9 Mon Sep 17 00:00:00 2001 From: Web3 Philosopher Date: Thu, 27 Jul 2023 13:22:09 +0100 Subject: [PATCH] check for duplicate consensus state ids (#66) * check for duplicate consensus state ids * clippy --- ismp/src/handlers/consensus.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ismp/src/handlers/consensus.rs b/ismp/src/handlers/consensus.rs index d0797ea..8694d20 100644 --- a/ismp/src/handlers/consensus.rs +++ b/ismp/src/handlers/consensus.rs @@ -115,6 +115,10 @@ where // check that we have an implementation of this client host.consensus_client(message.consensus_client_id)?; + if host.consensus_client_id(message.consensus_state_id).is_some() { + Err(Error::DuplicateConsensusStateId { consensus_state_id: message.consensus_state_id })? + } + // Store the initial state for the consensus client host.store_consensus_state(message.consensus_state_id, message.consensus_state)?; host.store_unbonding_period(message.consensus_state_id, message.unbonding_period)?;