Note multicasting

This is an initial implementation of note multicast, which sends posted
notes to other notedecks on the same network.

This came about after I nerd sniped myself thinking about p2p nostr on
local networks[1]

You can test this exclusively without joining any other relays by
passing -r multicast on the command line.

[1] https://damus.io/note1j50pseqwma38g3aqrsnhvld0m0ysdgppw6fjnvvcj0haeulgswgq80lpca

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-01-01 18:49:46 -06:00
parent f5afdd04a6
commit fe6206c546
16 changed files with 406 additions and 125 deletions

View File

@@ -6,7 +6,6 @@ use egui::widgets::text_edit::TextEdit;
use egui::{Frame, Layout};
use enostr::{FilledKeypair, FullKeypair, NoteId, RelayPool};
use nostrdb::{Ndb, Transaction};
use tracing::info;
use notedeck::{ImageCache, NoteCache};
@@ -62,9 +61,7 @@ impl PostAction {
}
};
let raw_msg = format!("[\"EVENT\",{}]", note.json().unwrap());
info!("sending {}", raw_msg);
pool.send(&enostr::ClientMessage::raw(raw_msg));
pool.send(&enostr::ClientMessage::event(note));
drafts.get_from_post_type(&self.post_type).clear();
Ok(())

View File

@@ -104,7 +104,7 @@ impl<'a> RelayView<'a> {
}
}
fn get_right_side_width(status: &RelayStatus) -> f32 {
fn get_right_side_width(status: RelayStatus) -> f32 {
match status {
RelayStatus::Connected => 150.0,
RelayStatus::Connecting => 160.0,
@@ -138,7 +138,7 @@ fn relay_frame(ui: &mut Ui) -> Frame {
.stroke(ui.style().visuals.noninteractive().bg_stroke)
}
fn show_connection_status(ui: &mut Ui, status: &RelayStatus) {
fn show_connection_status(ui: &mut Ui, status: RelayStatus) {
let fg_color = match status {
RelayStatus::Connected => ui.visuals().selection.bg_fill,
RelayStatus::Connecting => ui.visuals().warn_fg_color,
@@ -163,7 +163,7 @@ fn show_connection_status(ui: &mut Ui, status: &RelayStatus) {
});
}
fn get_connection_icon(status: &RelayStatus) -> egui::Image<'static> {
fn get_connection_icon(status: RelayStatus) -> egui::Image<'static> {
let img_data = match status {
RelayStatus::Connected => {
egui::include_image!("../../../../assets/icons/connected_icon_4x.png")