mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 16:56:30 +03:00
Minor clean ups
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
//! Peer channels for webxdc updates using iroh.
|
//! Peer channels for webxdc updates using iroh.
|
||||||
|
|
||||||
use crate::config::Config;
|
|
||||||
use crate::contact::ContactId;
|
|
||||||
use crate::context::Context;
|
|
||||||
use crate::message::{Message, MsgId};
|
|
||||||
use crate::tools::time;
|
|
||||||
use crate::webxdc::StatusUpdateItem;
|
|
||||||
use anyhow::{anyhow, Context as _, Result};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
use image::EncodableLayout;
|
use image::EncodableLayout;
|
||||||
use iroh_base::base32;
|
use iroh_base::base32;
|
||||||
@@ -15,11 +9,16 @@ use iroh_net::magic_endpoint::accept_conn;
|
|||||||
use iroh_net::NodeId;
|
use iroh_net::NodeId;
|
||||||
use iroh_net::{derp::DerpMode, key::SecretKey, MagicEndpoint};
|
use iroh_net::{derp::DerpMode, key::SecretKey, MagicEndpoint};
|
||||||
|
|
||||||
|
use crate::contact::ContactId;
|
||||||
|
use crate::context::Context;
|
||||||
|
use crate::message::{Message, MsgId};
|
||||||
|
use crate::tools::time;
|
||||||
|
use crate::webxdc::StatusUpdateItem;
|
||||||
|
|
||||||
impl Context {
|
impl Context {
|
||||||
/// Create magic endpoint and gossip for the context.
|
/// Create magic endpoint and gossip for the context.
|
||||||
pub async fn create_gossip(&self) -> Result<()> {
|
pub async fn create_gossip(&self) -> Result<()> {
|
||||||
let secret_key: SecretKey = self.get_or_create_iroh_keypair().await?;
|
let secret_key: SecretKey = self.generate_iroh_keypair();
|
||||||
|
|
||||||
println!("> our secret key: {}", base32::fmt(secret_key.to_bytes()));
|
println!("> our secret key: {}", base32::fmt(secret_key.to_bytes()));
|
||||||
|
|
||||||
if self.endpoint.lock().await.is_some() {
|
if self.endpoint.lock().await.is_some() {
|
||||||
@@ -146,17 +145,8 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the iroh gossip secret key from the database or create one.
|
/// Get the iroh gossip secret key from the database or create one.
|
||||||
pub async fn get_or_create_iroh_keypair(&self) -> Result<SecretKey> {
|
pub fn generate_iroh_keypair(&self) -> SecretKey {
|
||||||
Ok(SecretKey::generate())
|
SecretKey::generate()
|
||||||
/* match self.get_config_parsed(Config::IrohSecretKey).await? {
|
|
||||||
Some(key) => Ok(key),
|
|
||||||
None => {
|
|
||||||
let key = SecretKey::generate();
|
|
||||||
self.set_config(Config::IrohSecretKey, Some(&key.to_string()))
|
|
||||||
.await?;
|
|
||||||
Ok(key)
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user