Skip to content

Commit

Permalink
added debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
lla-dane committed Aug 21, 2024
1 parent faa9bd3 commit 9a42f8a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/floresta-wire/src/p2p_wire/chain_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ where
}

pub async fn run(&mut self, stop_signal: Arc<RwLock<bool>>) -> Result<(), WireError> {
println!("CHAIN SELECTOR");
self.create_connection(false).await;

info!("Starting ibd, selecting the best chain");
Expand All @@ -676,6 +677,8 @@ where
let new_sync_peer = rand::random::<usize>() % self.peer_ids.len();
self.1.sync_peer = *self.peer_ids.get(new_sync_peer).unwrap();

println!("REQUESTING BLOCKS");

try_and_log!(
self.request_headers(self.chain.get_best_block()?.1, self.1.sync_peer)
.await
Expand Down Expand Up @@ -780,6 +783,7 @@ where
}

PeerMessages::Ready(version) => {
println!("FROM PEER: READY");
self.handle_peer_ready(peer, &version).await?;
}

Expand Down
1 change: 1 addition & 0 deletions crates/floresta-wire/src/p2p_wire/running_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ where
kill_signal: Arc<RwLock<bool>>,
stop_signal: futures::channel::oneshot::Sender<()>,
) {
println!("RUNNING NODE");
try_and_log!(self.init_peers().await);
let startup_tip = self.chain.get_height().unwrap();

Expand Down
4 changes: 3 additions & 1 deletion crates/floresta-wire/src/p2p_wire/tests/running_node.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(test)]
mod tests_utils {
use std::collections::HashMap;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::time::Duration;

Expand Down Expand Up @@ -60,6 +61,7 @@ mod tests_utils {
node.peers.insert(i as u32, peer);
}
// let mut node = ManuallyDrop::new(Box::new(node));
let node = Box::new(node);

let kill_signal = Arc::new(RwLock::new(false));
// FIXME: This doesn't look very safe, but we need to coerce a &mut reference of the node
Expand All @@ -76,7 +78,7 @@ mod tests_utils {

task::spawn(node.run(kill_signal.clone(), sender));

task::sleep(Duration::from_secs(3)).await;
task::sleep(Duration::from_secs(4)).await;

let mut kill_guard = kill_signal.write().await;
*kill_guard = true;
Expand Down
1 change: 1 addition & 0 deletions crates/floresta-wire/src/p2p_wire/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl TestPeer {
.unwrap();

loop {
println!("RECEIVING");
let req = self.node_rx.recv().await.unwrap();

match req {
Expand Down

0 comments on commit 9a42f8a

Please sign in to comment.