Skip to content

Commit

Permalink
Merge pull request #58 from rustaceanrob/clean-peer
Browse files Browse the repository at this point in the history
node: rm fields
  • Loading branch information
rustaceanrob authored Aug 5, 2024
2 parents 1add428 + a3fe415 commit 221cc2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/node/peer_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ impl PeerMap {
self.num_peers = peer_num;
let mut peer = Peer::new(
peer_num,
ip.clone(),
port,
self.network,
self.mtx.clone(),
prx,
Expand All @@ -157,11 +155,11 @@ impl PeerMap {
if !connector.can_connect(&ip) {
return Err(PeerError::UnreachableSocketAddr);
}
let (reader, writer) = connector.connect(ip.clone(), port).await?;
let handle = tokio::spawn(async move { peer.run(reader, writer).await });
self.dialog
.send_dialog(format!("Connecting to {:?}:{}", ip, port))
.await;
let (reader, writer) = connector.connect(ip.clone(), port).await?;
let handle = tokio::spawn(async move { peer.run(reader, writer).await });
self.map.insert(
peer_num,
ManagedPeer {
Expand Down
8 changes: 1 addition & 7 deletions src/peers/peer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate tokio;
use std::time::Duration;

use bitcoin::{p2p::address::AddrV2, Network};
use bitcoin::Network;
use tokio::{
io::{AsyncRead, AsyncWrite, AsyncWriteExt},
select,
Expand All @@ -28,8 +28,6 @@ const CONNECTION_TIMEOUT: u64 = 2;

pub(crate) struct Peer {
nonce: u32,
ip_addr: AddrV2,
port: u16,
main_thread_sender: Sender<PeerThreadMessage>,
main_thread_recv: Receiver<MainThreadMessage>,
network: Network,
Expand All @@ -41,8 +39,6 @@ pub(crate) struct Peer {
impl Peer {
pub fn new(
nonce: u32,
ip_addr: AddrV2,
port: u16,
network: Network,
main_thread_sender: Sender<PeerThreadMessage>,
main_thread_recv: Receiver<MainThreadMessage>,
Expand All @@ -52,8 +48,6 @@ impl Peer {
let message_timer = MessageTimer::new();
Self {
nonce,
ip_addr,
port,
main_thread_sender,
main_thread_recv,
network,
Expand Down

0 comments on commit 221cc2d

Please sign in to comment.