Skip to content

Commit 1debdaf

Browse files
added logs
1 parent 0fbec00 commit 1debdaf

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ANNOUNCE_ADDRESS="192.168.1.59:5050"
2-
SERVER_ADDRESS="192.168.1.57:5050"
1+
ANNOUNCE_ADDRESS="192.168.1.57:5050"
2+
SERVER_ADDRESS="0.0.0.0:5050"
33
RUST_LOG="DEBUG"

src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub mod node_errors {
5959
#[error("Error recieving packet from {0:?}: {1:?}")]
6060
ReceievePacket(SocketAddr, EncSocketError),
6161

62-
#[allow(dead_code)]
62+
#[allow(dead_code)]
6363
#[error("Error reading propagation channel {0:?}: {1:?}")]
6464
PropagationRead(SocketAddr, RecvError),
6565

src/tools.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr};
1414
use std::sync::Arc;
1515
use std::time::{SystemTime, UNIX_EPOCH};
1616
use tokio::sync::broadcast::Sender;
17+
use tracing::{debug, error};
1718

1819
#[macro_export]
1920
macro_rules! box_array {
@@ -150,6 +151,10 @@ pub async fn new_block(
150151
.await
151152
.map_err(|e| NodeError::AddMainChainBlock(e.to_string()))?
152153
{
154+
debug!(
155+
"Block with diverging data {:?}",
156+
received_block.hash().unwrap()
157+
);
153158
// diverging data
154159
// get already existing block from the chain
155160
let existing_block = context
@@ -178,16 +183,19 @@ pub async fn new_block(
178183
}
179184

180185
// add block from the chain to the new data
181-
if new_data
186+
if let Err(e) = new_data
182187
.new_block(
183188
existing_block,
184189
&transactions,
185190
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0),
186191
received_timestamp as usize,
187192
)
188193
.await
189-
.is_err()
190194
{
195+
error!(
196+
"Error happened while adding new block to the new data: {:?}",
197+
e
198+
);
191199
return Ok(false);
192200
};
193201
}
@@ -300,8 +308,12 @@ mod dump_parse_tests {
300308
// 5050,
301309
// ));
302310

311+
// peers.insert(SocketAddr::new(
312+
// std::net::IpAddr::V4(Ipv4Addr::new(192, 168, 1, 57)),
313+
// 5050,
314+
// ));
303315
peers.insert(SocketAddr::new(
304-
std::net::IpAddr::V4(Ipv4Addr::new(192, 168, 1, 57)),
316+
std::net::IpAddr::V4(Ipv4Addr::new(192, 168, 1, 213)),
305317
5050,
306318
));
307319

0 commit comments

Comments
 (0)