mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
use as_bytes everywhere
This commit is contained in:
@@ -67,7 +67,10 @@ impl Context {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// restore old peers from db, if any
|
// restore old peers from db, if any
|
||||||
let peers = self.get_peers_for_topic(&topic.to_string()).await?;
|
let peers = self.get_peers_for_topic(topic).await?;
|
||||||
|
if peers.len() == 0 {
|
||||||
|
warn!(self, "joining gossip with zero peers: {peers:?}");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: add timeout as the returned future might be pending forever
|
// TODO: add timeout as the returned future might be pending forever
|
||||||
let connect_future = gossip.join(topic, peers).await?;
|
let connect_future = gossip.join(topic, peers).await?;
|
||||||
@@ -81,11 +84,11 @@ impl Context {
|
|||||||
/// Get list of [NodeId]s for one topic.
|
/// Get list of [NodeId]s for one topic.
|
||||||
/// This is used to rejoin a gossip group when reopening the xdc.
|
/// This is used to rejoin a gossip group when reopening the xdc.
|
||||||
/// Only [NodeId] is needed because the magic endpoint caches region and derp server for [NodeId]s.
|
/// Only [NodeId] is needed because the magic endpoint caches region and derp server for [NodeId]s.
|
||||||
pub async fn get_peers_for_topic(&self, topic: &str) -> Result<Vec<NodeId>> {
|
pub async fn get_peers_for_topic(&self, topic: TopicId) -> Result<Vec<NodeId>> {
|
||||||
self.sql
|
self.sql
|
||||||
.query_map(
|
.query_map(
|
||||||
"SELECT public_key FROM iroh_gossip_peers WHERE topic = ?",
|
"SELECT public_key FROM iroh_gossip_peers WHERE topic = ?",
|
||||||
(topic,),
|
(topic.as_bytes(),),
|
||||||
|row| {
|
|row| {
|
||||||
let data = row.get::<_, Vec<u8>>(0)?;
|
let data = row.get::<_, Vec<u8>>(0)?;
|
||||||
Ok(data)
|
Ok(data)
|
||||||
|
|||||||
@@ -460,8 +460,8 @@ pub(crate) async fn receive_imf_inner(
|
|||||||
.add_node_addr(node_addr.clone())
|
.add_node_addr(node_addr.clone())
|
||||||
.context("Failed to add node address")?;
|
.context("Failed to add node address")?;
|
||||||
|
|
||||||
|
let node_id = node_addr.node_id;
|
||||||
for topic in topics {
|
for topic in topics {
|
||||||
let node_id = node_addr.node_id;
|
|
||||||
context
|
context
|
||||||
.add_peer_for_topic(instance_id, topic, node_id)
|
.add_peer_for_topic(instance_id, topic, node_id)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user