From ff6b85d1955c31eeb0293aed0c82e72efc05b1dd Mon Sep 17 00:00:00 2001 From: benthecarman Date: Fri, 29 Jan 2021 09:28:57 -0600 Subject: [PATCH] Ignore block messages while syncing (#2587) --- .../node/networking/peer/DataMessageHandler.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 6b797166ff..f3773c18cd 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 @@ -378,18 +378,19 @@ case class DataMessageHandler( invMsg: InventoryMessage, peerMsgSender: PeerMessageSender): Future[DataMessageHandler] = { logger.info(s"Received inv=${invMsg}") - val getData = GetDataMessage(invMsg.inventories.map { + val getData = GetDataMessage(invMsg.inventories.flatMap { case Inventory(TypeIdentifier.MsgBlock, hash) => // only request the merkle block if we are spv enabled appConfig.nodeType match { case NodeType.SpvNode => - Inventory(TypeIdentifier.MsgFilteredBlock, hash) + Some(Inventory(TypeIdentifier.MsgFilteredBlock, hash)) case NodeType.NeutrinoNode | NodeType.FullNode => - Inventory(TypeIdentifier.MsgWitnessBlock, hash) + if (syncing) None + else Some(Inventory(TypeIdentifier.MsgWitnessBlock, hash)) case NodeType.BitcoindBackend => throw new RuntimeException("This is impossible") } - case other: Inventory => other + case other: Inventory => Some(other) }) peerMsgSender.sendMsg(getData).map(_ => this) }