Skip to content

Commit

Permalink
clone values
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden committed Sep 23, 2024
1 parent 668fd3b commit 4fe4085
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions bridges/snowbridge/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,15 @@ impl<UniversalLocation, EthereumNetwork, OutboundQueue, AgentHashedDescription,
return Err(SendError::NotApplicable)
}

let dest = destination.take().ok_or(SendError::MissingArgument)?;
// Cloning destination to avoid modifying the value so subsequent exporters can use it.
let dest = destination.clone().take().ok_or(SendError::MissingArgument)?;
if dest != Here {
log::trace!(target: "xcm::ethereum_blob_exporter", "skipped due to unmatched remote destination {dest:?}.");
// We need to make sure that mutable variables are not consumed in case of
// `NotApplicable`, since they may be used by a subsequent exporter.
*destination = Some(dest);
return Err(SendError::NotApplicable)
}

let universal_source_value = universal_source.clone();
let (local_net, local_sub) = universal_source
// Cloning universal_source to avoid modifying the value so subsequent exporters can use it.
let (local_net, local_sub) = universal_source.clone()
.take()
.ok_or_else(|| {
log::error!(target: "xcm::ethereum_blob_exporter", "universal source not provided.");
Expand All @@ -92,10 +90,6 @@ impl<UniversalLocation, EthereumNetwork, OutboundQueue, AgentHashedDescription,

if Ok(local_net) != universal_location.global_consensus() {
log::trace!(target: "xcm::ethereum_blob_exporter", "skipped due to unmatched relay network {local_net:?}.");
// We need to make sure that mutable variables are not consumed in case of
// `NotApplicable`, since they may be used by a subsequent exporter.
*universal_source = universal_source_value.clone();
*destination = Some(dest);
return Err(SendError::NotApplicable)
}

Expand Down

0 comments on commit 4fe4085

Please sign in to comment.