This commit is contained in:
Sebastian Klähn
2024-02-09 09:10:56 +01:00
parent bd37c36143
commit 8385ba92c7
2 changed files with 8 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ impl Context {
if self.endpoint.lock().await.is_some() { if self.endpoint.lock().await.is_some() {
warn!( warn!(
self, self,
"Tried to create gossip even tough there still exists an instance" "Tried to create endpoint even though there is already one."
); );
return Ok(()); return Ok(());
} }

View File

@@ -501,6 +501,11 @@ impl Context {
if send_now { if send_now {
if let Some(ref topic) = status_update.gossip_topic { if let Some(ref topic) = status_update.gossip_topic {
// find out if any row with `topic = topic` exists in the gossip_peers table // find out if any row with `topic = topic` exists in the gossip_peers table
let topic = TopicId::from_str(&iroh_base::base32::fmt(
topic.get(0..32).context("Can't get 32 bytes from topic")?,
))?;
let topic_exists = self let topic_exists = self
.sql .sql
.query_row_optional( .query_row_optional(
@@ -512,10 +517,6 @@ impl Context {
.context("Failed to check if gossip topic exists")? .context("Failed to check if gossip topic exists")?
.is_some(); .is_some();
let topic = TopicId::from_str(&iroh_base::base32::fmt(
topic.get(0..32).context("Can't get 32 bytes from topic")?,
))?;
if !topic_exists { if !topic_exists {
info!( info!(
self, self,
@@ -531,10 +532,10 @@ impl Context {
.await .await
.unwrap() .unwrap()
.node_id; .node_id;
self.join_and_subscribe_topic(topic, instance_msg_id)
.await?;
self.add_peer_for_topic(instance_msg_id, topic, node_id) self.add_peer_for_topic(instance_msg_id, topic, node_id)
.await?; .await?;
self.join_and_subscribe_topic(topic, instance_msg_id)
.await?;
ephemeral = false; ephemeral = false;
} else { } else {
if let Some(ref gossip) = *self.gossip.lock().await { if let Some(ref gossip) = *self.gossip.lock().await {