Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert myself into the relay graph even when I don't have neighbors #30

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/daemon/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ use super::{link_connection::LinkConnection, DaemonContext};
pub async fn gossip_loop(ctx: DaemonContext) -> anyhow::Result<()> {
let mut sleep_timer = smol::Timer::interval(Duration::from_secs(5));
loop {
// first insert ourselves
let am_i_relay = !ctx.config.in_routes.is_empty();
ctx.relay_graph
.write()
.insert_identity(IdentityDescriptor::new(
&ctx.identity,
&ctx.onion_sk,
am_i_relay,
))?;
let once = async {
let neighs = ctx.table.all_neighs();
if neighs.is_empty() {
Expand All @@ -39,16 +48,6 @@ pub async fn gossip_loop(ctx: DaemonContext) -> anyhow::Result<()> {

/// One round of gossip with a particular neighbor.
async fn gossip_once(ctx: &DaemonContext, conn: &LinkConnection) -> anyhow::Result<()> {
// first insert ourselves
let am_i_relay = !ctx.config.in_routes.is_empty();
ctx.relay_graph
.write()
.insert_identity(IdentityDescriptor::new(
&ctx.identity,
&ctx.onion_sk,
am_i_relay,
))?;

fetch_identity(ctx, conn).await?;
sign_adjacency(ctx, conn).await?;
gossip_graph(ctx, conn).await?;
Expand Down