Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 3ec8385

Browse files
committed
[CSL-1822] Print header of received block less often
Before this commit online and up-to-date node was printing header of a newly created block received from the network 5 times. It's quite a lot, especially considering that each header takes about 9 lines. Few observations: 1. Printing header in 'handleUnsolicitedHeader' makes more sense than in 'addHeaderToBlockRequestQueue', because it's called earlier and allows us to inspect header before we do something with it. 2. Printing header after we processed it is not useful, because we must have printed it already. Printing hash is enough.
1 parent 5d30750 commit 3ec8385

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

block/src/Pos/Block/Network/Announce.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ announceBlock
4343
:: BlockWorkMode ctx m
4444
=> EnqueueMsg m -> MainBlockHeader -> m (Map NodeId (m ()))
4545
announceBlock enqueue header = do
46-
logDebug $ sformat ("Announcing header to others:\n"%build) header
46+
logDebug $ sformat ("Announcing header to others: "%shortHashF)
47+
(headerHash header)
4748
enqueue (MsgAnnounceBlockHeader OriginSender) (\addr _ -> announceBlockDo addr)
4849
where
4950
announceBlockDo

block/src/Pos/Block/Network/Logic.hs

+7-6
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,8 @@ handleUnsolicitedHeader
184184
-> m ()
185185
handleUnsolicitedHeader header nodeId = do
186186
logDebug $ sformat
187-
("handleUnsolicitedHeader: single header "%shortHashF%
188-
" was propagated, processing")
189-
hHash
187+
("handleUnsolicitedHeader: single header was propagated, processing:\n"
188+
%build) header
190189
classificationRes <- classifyNewHeader header
191190
-- TODO: should we set 'To' hash to hash of header or leave it unlimited?
192191
case classificationRes of
@@ -399,7 +398,8 @@ addHeaderToBlockRequestQueue
399398
-> Bool -- ^ Was classified as chain continuation
400399
-> m ()
401400
addHeaderToBlockRequestQueue nodeId header continues = do
402-
logDebug $ sformat ("addToBlockRequestQueue, : "%build) header
401+
let hHash = headerHash header
402+
logDebug $ sformat ("addToBlockRequestQueue, : "%shortHashF) hHash
403403
queue <- view (lensOf @BlockRetrievalQueueTag)
404404
lastKnownH <- view (lensOf @LastKnownHeaderTag)
405405
added <- atomically $ do
@@ -409,7 +409,7 @@ addHeaderToBlockRequestQueue nodeId header continues = do
409409
if added
410410
then logDebug $ sformat ("Added headers to block request queue: nodeId="%build%
411411
", header="%build)
412-
nodeId (headerHash header)
412+
nodeId hHash
413413
else logWarning $ sformat ("Failed to add headers from "%build%
414414
" to block retrieval queue: queue is full")
415415
nodeId
@@ -581,7 +581,8 @@ relayBlock enqueue (Right mainBlk) = do
581581
recoveryInProgress >>= \case
582582
True -> logDebug "Not relaying block in recovery mode"
583583
False -> do
584-
logDebug $ sformat ("Calling announceBlock for "%build%".") (mainBlk ^. gbHeader)
584+
logDebug $ sformat ("Calling announceBlock for "%shortHashF%".")
585+
(mainBlk ^. gbHeader . headerHashG)
585586
void $ announceBlock enqueue $ mainBlk ^. gbHeader
586587

587588
----------------------------------------------------------------------------

0 commit comments

Comments
 (0)