Move RelayAssignment definition

This commit is contained in:
Mike Dilger 2023-02-07 21:31:32 +13:00
parent 4fbd3c566a
commit 0fa0c669fc
3 changed files with 18 additions and 12 deletions

View File

@ -5,8 +5,8 @@ use crate::db::{DbEvent, DbEventSeen, DbPersonRelay, DbRelay, Direction};
use crate::error::Error;
use crate::globals::GLOBALS;
use crate::people::People;
use crate::relay_info::{RelayAssignment, RelayInfo};
use crate::relay_picker::RelayPicker;
use crate::relay_info::RelayInfo;
use crate::relay_picker::{RelayAssignment, RelayPicker};
use crate::tags::{
add_event_to_tags, add_pubkey_hex_to_tags, add_pubkey_to_tags, add_subject_to_tags_if_missing,
keys_from_text, notes_from_text,

View File

@ -1,5 +1,5 @@
use crate::db::DbRelay;
use nostr_types::PublicKeyHex;
use crate::relay_picker::RelayAssignment;
/// All the per-relay information we need kept hot in memory
#[derive(Debug, Clone)]
@ -9,11 +9,3 @@ pub struct RelayInfo {
pub assignment: Option<RelayAssignment>,
//pub subscriptions: Vec<String>,
}
/// A RelayAssignment is a record of a relay which is serving (or will serve) the general
/// feed for a set of public keys.
#[derive(Debug, Clone)]
pub struct RelayAssignment {
pub relay: DbRelay,
pub pubkeys: Vec<PublicKeyHex>,
}

View File

@ -1,11 +1,18 @@
use crate::db::{DbPersonRelay, DbRelay, Direction};
use crate::error::Error;
use crate::globals::GLOBALS;
use crate::relay_info::RelayAssignment;
use nostr_types::{PublicKeyHex, RelayUrl, Unixtime};
use std::collections::HashMap;
use std::fmt;
/// A RelayAssignment is a record of a relay which is serving (or will serve) the general
/// feed for a set of public keys.
#[derive(Debug, Clone)]
pub struct RelayAssignment {
pub relay: DbRelay,
pub pubkeys: Vec<PublicKeyHex>,
}
/// Ways that the RelayPicker can fail
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(clippy::enum_variant_names)]
@ -56,6 +63,13 @@ pub struct RelayPicker {
/// A ranking of relays per person.
// best() and take() don't change this.
pub person_relay_scores: Vec<(PublicKeyHex, RelayUrl, u64)>,
// Which relays we are connected to
//pub connected: HashSet<RelayUrl>,
// Current relay assignments
//pub assignments: HashMap<RelayUrl, RelayAssignment>,
}
impl RelayPicker {