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

Change Neighborhood DB to contain Free World Bit and Country code #467

Open
czarte opened this issue Apr 26, 2024 · 0 comments
Open

Change Neighborhood DB to contain Free World Bit and Country code #467

czarte opened this issue Apr 26, 2024 · 0 comments
Assignees

Comments

@czarte
Copy link
Collaborator

czarte commented Apr 26, 2024

We have decided to contain Fere World Bit and Country Code in NodeRecordInner_0v1

#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
#[allow(non_camel_case_types)]
pub struct NodeRecordInner_0v1 {
    pub public_key: PublicKey,
    pub earning_wallet: Wallet,
    pub rate_pack: RatePack,
    pub neighbors: BTreeSet<PublicKey>,
    pub accepts_connections: bool,
    pub routes_data: bool,
    pub version: u32,
    pub free_world_bit: bool,
    pub country_code: String,
}

There is need to be implemented location: Option<NodeLocation> into impl NodeRecord

impl NodeRecord {
    pub fn new(
        public_key: &PublicKey,
        ...
        location: Option<NodeLocation>,
    ) -> NodeRecord {
        let mut free_world = false;
        let mut country = String::default();
        match location.as_ref() {
            Some(node_location) => {
                free_world = node_location.free_world;
                country = node_location.country.clone();
            },
            None => {  },
        };
        let mut node_record = NodeRecord {
            metadata: NodeRecordMetadata::new(location),
            inner: NodeRecordInner_0v1 {
                public_key: public_key.clone(),
                ...
                free_world_bit: free_world,
                country_code: country
            },
            signed_gossip: PlainData::new(&[]),
            signature: CryptData::new(&[]),
        };
        node_record.regenerate_signed_gossip(cryptde);
        node_record
    }
}

in NodeRecordMetadata we want to store the FreeWorldScore to handle the undesirability of the current Node to Exiting our Routes.

  1. Add node_location: NodeLocation to struct NodeRecordMetadata
    pub struct NodeRecordMetadata {
        pub last_update: u32,
        pub node_addr_opt: Option<NodeAddr>,
        pub unreachable_hosts: HashSet<String>,
        pub node_location: Option<NodeLocation>,
        pub free_world_score: u32
    }
    
  2. Put node_location to constructor pub fn new(node_location: NodeLocation) into impl NodeRecordMetadata
  3. Introduce new struct NodeData to pass it in NodeRecord::new() instead of too many of variables:
    NodeData {
        public_key: &PublicKey,
        earning_wallet: Wallet,
        rate_pack: RatePack,
        accepts_connections: bool,
        routes_data: bool,
        version: u32,
        cryptde: &dyn CryptDE,
        node_location: NodeLocation
    }
    
@czarte czarte self-assigned this May 15, 2024
@kauri-hero kauri-hero transferred this issue from MASQ-Project/MASQ-Node-issues Aug 10, 2024
@kauri-hero kauri-hero added this to the Country Selection milestone Aug 10, 2024
@github-project-automation github-project-automation bot moved this to Development In Progress in MASQNode Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 Review + QA in Progress
Status: Development In Progress
Development

No branches or pull requests

2 participants