Skip to content

Commit

Permalink
Ignore block messages while syncing (#2587)
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 29, 2021
1 parent ec65e48 commit d608a44
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -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)
}
Expand Down

0 comments on commit d608a44

Please sign in to comment.