From 898d2b44ee97f57fc68991d120ba4ab0c10330b4 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Tue, 5 Mar 2024 13:47:03 -0600 Subject: [PATCH] Fix bug where we were executing block callbacks when we hadn't seen a block header (#5455) * Fix bug where we were executing block callbacks when we hadn't seen a block header * reduce log to DEBUG --- .../node/networking/peer/DataMessageHandlerTest.scala | 2 ++ .../node/networking/peer/DataMessageHandler.scala | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala b/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala index 9932676e78..784e4b69f8 100644 --- a/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala +++ b/node-test/src/test/scala/org/bitcoins/node/networking/peer/DataMessageHandlerTest.scala @@ -100,6 +100,8 @@ class DataMessageHandlerTest extends NodeTestWithCachedBitcoindNewest { nodeCallbacks = NodeCallbacks.onBlockReceived(callback) _ = node.nodeAppConfig.addCallbacks(nodeCallbacks) hash <- bitcoind.generateToAddress(blocks = 1, junkAddress).map(_.head) + _ <- NodeTestUtil.awaitAllSync(node, bitcoind) + _ <- node.downloadBlocks(Vector(hash.flip)) result = Await.result(resultP.future, 30.seconds) } yield assert(result.blockHeader.hashBE == hash) } diff --git a/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala b/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala index aad0bb4c07..932d1171b4 100644 --- a/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala +++ b/node/src/main/scala/org/bitcoins/node/networking/peer/DataMessageHandler.scala @@ -310,11 +310,7 @@ case class DataMessageHandler( HeadersMessage(CompactSizeUInt.one, Vector(block.blockHeader)) val newDmhF = handleDataPayload(payload = headersMessage, peerData = peerData) - newDmhF.flatMap { dmh => - appConfig.callBacks - .executeOnBlockReceivedCallbacks(block) - .map(_ => dmh) - } + newDmhF } else { logger.info( s"Received block=${block.blockHeader.hash.flip.hex} state=$state") @@ -508,7 +504,7 @@ case class DataMessageHandler( stopBlockHash: DoubleSha256DigestBE, startHeightOpt: Option[Int], syncNodeState: SyncNodeState): Future[Option[NodeState.FilterSync]] = { - logger.info(s"Beginning to sync filters to stopBlockHashBE=$stopBlockHash") + logger.debug(s"Beginning to sync filters to stopBlockHashBE=$stopBlockHash") val fs = syncNodeState match { case x @ (_: HeaderSync | _: FilterHeaderSync) =>