diff --git a/sn_client/src/api.rs b/sn_client/src/api.rs index 44afb567df..2e171ebf7f 100644 --- a/sn_client/src/api.rs +++ b/sn_client/src/api.rs @@ -108,20 +108,10 @@ impl Client { // TODO: shall client bearing owner's discord user name, to be reflected in the cash_notes? #[cfg(not(feature = "open-metrics"))] - let network_builder = NetworkBuilder::new( - Keypair::generate_ed25519(), - local, - root_dir, - "maidsafe_client".to_string(), - ); + let network_builder = NetworkBuilder::new(Keypair::generate_ed25519(), local, root_dir); #[cfg(feature = "open-metrics")] - let mut network_builder = NetworkBuilder::new( - Keypair::generate_ed25519(), - local, - root_dir, - "maidsafe_client".to_string(), - ); + let mut network_builder = NetworkBuilder::new(Keypair::generate_ed25519(), local, root_dir); #[cfg(feature = "open-metrics")] network_builder.metrics_registry(Registry::default()); diff --git a/sn_client/src/uploader/tests/setup.rs b/sn_client/src/uploader/tests/setup.rs index 3e8d678d7c..15dc536685 100644 --- a/sn_client/src/uploader/tests/setup.rs +++ b/sn_client/src/uploader/tests/setup.rs @@ -425,12 +425,7 @@ pub fn start_uploading_with_steps( // Build a very simple client struct for testing. This does not connect to any network. // The UploaderInterface eliminates the need for direct networking in tests. pub fn build_unconnected_client(root_dir: PathBuf) -> Result { - let network_builder = NetworkBuilder::new( - Keypair::generate_ed25519(), - true, - root_dir, - "maidsafe_client".to_string(), - ); + let network_builder = NetworkBuilder::new(Keypair::generate_ed25519(), true, root_dir); let (network, ..) = network_builder.build_client()?; let client = Client { network: network.clone(), diff --git a/sn_networking/src/driver.rs b/sn_networking/src/driver.rs index 1d1af4b7fc..c104ec14cb 100644 --- a/sn_networking/src/driver.rs +++ b/sn_networking/src/driver.rs @@ -206,11 +206,10 @@ pub struct NetworkBuilder { metrics_registry: Option, #[cfg(feature = "open-metrics")] metrics_server_port: u16, - owner: String, } impl NetworkBuilder { - pub fn new(keypair: Keypair, local: bool, root_dir: PathBuf, owner: String) -> Self { + pub fn new(keypair: Keypair, local: bool, root_dir: PathBuf) -> Self { Self { is_behind_home_network: false, keypair, @@ -224,7 +223,6 @@ impl NetworkBuilder { metrics_registry: None, #[cfg(feature = "open-metrics")] metrics_server_port: 0, - owner, } } @@ -317,7 +315,6 @@ impl NetworkBuilder { }; let listen_addr = self.listen_addr; - let owner = self.owner.clone(); let (network, events_receiver, mut swarm_driver) = self.build( kad_cfg, @@ -325,7 +322,6 @@ impl NetworkBuilder { false, ProtocolSupport::Full, IDENTIFY_NODE_VERSION_STR.to_string(), - owner, )?; // Listen on the provided address @@ -371,15 +367,12 @@ impl NetworkBuilder { .ok_or_else(|| NetworkError::InvalidCloseGroupSize)?, ); - let owner = self.owner.clone(); - let (network, net_event_recv, driver) = self.build( kad_cfg, None, true, ProtocolSupport::Outbound, IDENTIFY_CLIENT_VERSION_STR.to_string(), - owner, )?; Ok((network, net_event_recv, driver)) @@ -393,7 +386,6 @@ impl NetworkBuilder { is_client: bool, req_res_protocol: ProtocolSupport, identify_version: String, - owner: String, ) -> Result<(Network, mpsc::Receiver, SwarmDriver)> { let peer_id = PeerId::from(self.keypair.public()); // vdash metric (if modified please notify at https://github.com/happybeing/vdash/issues): @@ -587,7 +579,6 @@ impl NetworkBuilder { peer_id: Arc::new(peer_id), root_dir_path: Arc::new(self.root_dir), keypair: Arc::new(self.keypair), - owner, }, network_event_receiver, swarm_driver, diff --git a/sn_networking/src/lib.rs b/sn_networking/src/lib.rs index 23943e91c2..75d51ab1e2 100644 --- a/sn_networking/src/lib.rs +++ b/sn_networking/src/lib.rs @@ -158,16 +158,9 @@ pub struct Network { pub peer_id: Arc, pub root_dir_path: Arc, keypair: Arc, - /// node owner's discord username, in readable format - owner: String, } impl Network { - /// Returns of the discord user_name of the node's owner - pub fn owner(&self) -> String { - self.owner.clone() - } - /// Signs the given data with the node's keypair. pub fn sign(&self, msg: &[u8]) -> Result> { self.keypair.sign(msg).map_err(NetworkError::from) @@ -1053,13 +1046,9 @@ mod tests { #[test] fn test_network_sign_verify() -> eyre::Result<()> { - let (network, _, _) = NetworkBuilder::new( - Keypair::generate_ed25519(), - false, - std::env::temp_dir(), - "maidsafe_test".to_string(), - ) - .build_client()?; + let (network, _, _) = + NetworkBuilder::new(Keypair::generate_ed25519(), false, std::env::temp_dir()) + .build_client()?; let msg = b"test message"; let sig = network.sign(msg)?; assert!(network.verify(msg, &sig)); diff --git a/sn_node/src/node.rs b/sn_node/src/node.rs index ace0473d59..559e41d081 100644 --- a/sn_node/src/node.rs +++ b/sn_node/src/node.rs @@ -133,8 +133,7 @@ impl NodeBuilder { (metrics_registry, node_metrics) }; - let mut network_builder = - NetworkBuilder::new(self.keypair, self.local, self.root_dir, self.owner.clone()); + let mut network_builder = NetworkBuilder::new(self.keypair, self.local, self.root_dir); network_builder.listen_addr(self.addr); #[cfg(feature = "open-metrics")] @@ -156,6 +155,7 @@ impl NodeBuilder { reward_address: Arc::new(reward_address), #[cfg(feature = "open-metrics")] node_metrics, + owner: self.owner.clone(), }; let running_node = RunningNode { network, @@ -188,6 +188,8 @@ pub(crate) struct Node { reward_address: Arc, #[cfg(feature = "open-metrics")] pub(crate) node_metrics: NodeMetrics, + /// node owner's discord username, in readable format + owner: String, } impl Node { @@ -389,9 +391,10 @@ impl Node { event_header = "QueryRequestReceived"; let network = self.network.clone(); let payment_address = *self.reward_address; + let owner = self.owner.clone(); let _handle = spawn(async move { - let res = Self::handle_query(&network, query, payment_address).await; + let res = Self::handle_query(&network, query, payment_address, owner).await; trace!("Sending response {res:?}"); network.send_response(res, channel); @@ -564,6 +567,7 @@ impl Node { network: &Network, query: Query, payment_address: MainPubkey, + owner: String, ) -> Response { let resp: QueryResponse = match query { Query::GetStoreCost(address) => { @@ -590,6 +594,7 @@ impl Node { cost, &address, "ing_metrics, + owner, ), payment_address, peer_address: NetworkAddress::from_peer(self_id), diff --git a/sn_node/src/quote.rs b/sn_node/src/quote.rs index a673e0afba..5f19f95cdc 100644 --- a/sn_node/src/quote.rs +++ b/sn_node/src/quote.rs @@ -19,6 +19,7 @@ impl Node { cost: NanoTokens, address: &NetworkAddress, quoting_metrics: &QuotingMetrics, + owner: String, ) -> Result { let content = address.as_xorname().unwrap_or_default(); let timestamp = std::time::SystemTime::now(); @@ -27,7 +28,7 @@ impl Node { cost, timestamp, quoting_metrics, - network.owner(), + owner.clone(), ); let Ok(signature) = network.sign(&bytes) else { @@ -39,7 +40,7 @@ impl Node { cost, timestamp, quoting_metrics: quoting_metrics.clone(), - reason: network.owner(), + reason: owner, pub_key: network.get_pub_key(), signature, };