Skip to content

Commit

Permalink
Update twin relays
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanElawady committed Mar 26, 2024
1 parent d164d7a commit 319af11
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/relay/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,21 @@ async fn update_cache_relays(envelope: &Envelope, twin_db: &impl TwinDB) -> Resu
if envelope.relays.len() == 0 {

Check warning on line 219 in src/relay/api.rs

View workflow job for this annotation

GitHub Actions / Test-Clippy-Build

length comparison to zero
return Ok(());
}
let twin = twin_db
let mut twin = twin_db
.get_twin(envelope.source.twin)
.await?
.ok_or_else(|| anyhow::Error::msg("unknown twin source"))?;
let envelope_relays = RelayDomains::new(&envelope.relays);
if let Some(twin_relays) = twin.relay.clone() {
if twin_relays != envelope_relays {
twin_db.set_twin(twin).await?;
match twin.relay {
Some(twin_relays) => {
if twin_relays == envelope_relays {
return Ok(());
}
twin.relay = Some(envelope_relays);
}
None => twin.relay = Some(envelope_relays),
}
Ok(())
twin_db.set_twin(twin).await
}

type Writer = SplitSink<WebSocketStream<Upgraded>, Message>;
Expand Down

0 comments on commit 319af11

Please sign in to comment.