Skip to content

Commit

Permalink
Revert "Add 'E' tags when generating events"
Browse files Browse the repository at this point in the history
This reverts commit 94651b8.
  • Loading branch information
mikedilger committed Oct 19, 2023
1 parent 543f7bd commit 5c7942e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
10 changes: 4 additions & 6 deletions gossip-lib/src/overlord/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::people::Person;
use crate::person_relay::PersonRelay;
use crate::relay::Relay;
use crate::tags::{
add_addr_to_tags, add_event_parent_to_tags, add_event_to_tags, add_pubkey_hex_to_tags,
add_pubkey_to_tags, add_subject_to_tags_if_missing,
add_addr_to_tags, add_event_to_tags, add_pubkey_hex_to_tags, add_pubkey_to_tags,
add_subject_to_tags_if_missing,
};
use gossip_relay_picker::{Direction, RelayAssignment};
use http::StatusCode;
Expand Down Expand Up @@ -1403,19 +1403,17 @@ impl Overlord {
// Add an 'e' tag for the root
add_event_to_tags(&mut tags, root, "root").await;

// Add an 'e' and 'E' tag for the note we are replying to
// Add an 'e' tag for the note we are replying to
add_event_to_tags(&mut tags, parent_id, "reply").await;
add_event_parent_to_tags(&mut tags, parent_id).await;
} else {
let ancestors = parent.referred_events();
if ancestors.is_empty() {
// parent is the root
add_event_to_tags(&mut tags, parent_id, "root").await;
} else {
// Add an 'e' and 'E' tag for the note we are replying to
// Add an 'e' tag for the note we are replying to
// (and we don't know about the root, the parent is malformed).
add_event_to_tags(&mut tags, parent_id, "reply").await;
add_event_parent_to_tags(&mut tags, parent_id).await;
}
}

Expand Down
25 changes: 0 additions & 25 deletions gossip-lib/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,6 @@ pub async fn add_pubkey_to_tags(existing_tags: &mut Vec<Tag>, added: &PublicKey)
add_pubkey_hex_to_tags(existing_tags, &added.as_hex_string().into()).await
}

pub async fn add_event_parent_to_tags(existing_tags: &mut Vec<Tag>, added: Id) -> usize {
let newtag = Tag::EventParent {
id: added,
recommended_relay_url: Relay::recommended_relay_for_reply(added)
.await
.ok()
.flatten()
.map(|rr| rr.to_unchecked_url()),
trailing: Vec::new(),
};

match existing_tags.iter().position(|existing_tag| {
matches!(
existing_tag,
Tag::EventParent { id: existing_e, .. } if existing_e.0 == added.0
)
}) {
None => {
existing_tags.push(newtag);
existing_tags.len() - 1
}
Some(idx) => idx,
}
}

pub async fn add_event_to_tags(existing_tags: &mut Vec<Tag>, added: Id, marker: &str) -> usize {
let newtag = Tag::Event {
id: added,
Expand Down

0 comments on commit 5c7942e

Please sign in to comment.