Skip to content

Commit 6912fab

Browse files
committed
minor cleanup
1 parent 15d03ca commit 6912fab

File tree

3 files changed

+7
-32
lines changed

3 files changed

+7
-32
lines changed

p2p/src/net/default_backend/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ where
146146
impl MessagingService for MessagingHandle {
147147
async fn send_message(&mut self, peer_id: PeerId, message: SyncMessage) -> crate::Result<()> {
148148
// Note: send_message was made async to be able to use a bounded channel in tests.
149-
// TODO: it may make sense to use a bounded channel in production as well. One possible
150-
// reason for this might be to limit the number of BlockResponse messages that can exist
151-
// at the same time. E.g. currently sync::Peer will produce a BlockResponse for each
152-
// requested block almost immediately. The maximum number of simultaneously requested
153-
// blocks is 500 per peer, a block can be up to 1Mb in size, so several malicious peers
154-
// can eat up several Gb of RAM on the node.
155149
Ok(self.command_sender.send(types::Command::SendMessage {
156150
peer_id,
157151
message: message.into(),

p2p/src/sync/peer_v1.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -290,23 +290,17 @@ where
290290
.await?;
291291

292292
if headers.is_empty() {
293-
log::warn!(
294-
concat!(
295-
"[peer id = {}] Got new tip event with block id {}, ",
296-
"but there is nothing to send"
297-
),
293+
log::debug!(
294+
"[peer id = {}] Got new tip event with block id {}, but there is nothing to send",
298295
self.id(),
299296
new_tip_id,
300297
);
301298
} else if best_block_id != new_tip_id {
302299
// If we got here, another "new tip" event should be generated soon,
303300
// so we may ignore this one (and it makes sense to ignore it to avoid sending
304301
// the same header list multiple times).
305-
log::warn!(
306-
concat!(
307-
"[peer id = {}] Got new tip event with block id {}, ",
308-
"but the tip has changed since then to {}"
309-
),
302+
log::info!(
303+
"[peer id = {}] Got new tip event with block id {}, but the tip has changed since then to {}",
310304
self.id(),
311305
new_tip_id,
312306
best_block_id
@@ -357,9 +351,6 @@ where
357351
async fn request_headers(&mut self) -> Result<()> {
358352
let locator = self.chainstate_handle.call(|this| Ok(this.get_locator()?)).await?;
359353
if locator.len() > *self.p2p_config.protocol_config.msg_max_locator_count {
360-
// Note: msg_max_locator_count is not supposed to be configurable outside of tests,
361-
// so we should never get here in production code. Moreover, currently it's not
362-
// modified even in tests. TODO: make it a constant.
363354
log::warn!(
364355
"[peer id = {}] Sending locator of the length {}, which exceeds the maximum length {:?}",
365356
self.id(),

p2p/src/sync/peer_v2.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,8 @@ where
287287
.await?;
288288

289289
if headers.is_empty() {
290-
log::warn!(
291-
concat!(
292-
"[peer id = {}] Got new tip event with block id {}, ",
293-
"but there is nothing to send"
294-
),
290+
log::debug!(
291+
"[peer id = {}] Got new tip event with block id {}, but there is nothing to send",
295292
self.id(),
296293
new_tip_id,
297294
);
@@ -300,10 +297,7 @@ where
300297
// so we may ignore this one (and it makes sense to ignore it to avoid sending
301298
// the same header list multiple times).
302299
log::warn!(
303-
concat!(
304-
"[peer id = {}] Got new tip event with block id {}, ",
305-
"but the tip has changed since then to {}"
306-
),
300+
"[peer id = {}] Got new tip event with block id {}, but the tip has changed since then to {}",
307301
self.id(),
308302
new_tip_id,
309303
best_block_id
@@ -354,10 +348,6 @@ where
354348
async fn request_headers(&mut self) -> Result<()> {
355349
let locator = self.chainstate_handle.call(|this| Ok(this.get_locator()?)).await?;
356350
if locator.len() > *self.p2p_config.protocol_config.msg_max_locator_count {
357-
// Note: msg_max_locator_count is not supposed to be configurable outside of tests,
358-
// so we should never get here in production code. Moreover, currently it's not
359-
// modified even in tests. TODO: make it a constant.
360-
// See https://github.com/mintlayer/mintlayer-core/issues/1201
361351
log::warn!(
362352
"[peer id = {}] Sending locator of the length {}, which exceeds the maximum length {:?}",
363353
self.id(),

0 commit comments

Comments
 (0)