mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-20 02:11:40 +01:00
Ignore block messages while syncing (#2587)
This commit is contained in:
parent
beac2be195
commit
ff6b85d195
@ -378,18 +378,19 @@ case class DataMessageHandler(
|
|||||||
invMsg: InventoryMessage,
|
invMsg: InventoryMessage,
|
||||||
peerMsgSender: PeerMessageSender): Future[DataMessageHandler] = {
|
peerMsgSender: PeerMessageSender): Future[DataMessageHandler] = {
|
||||||
logger.info(s"Received inv=${invMsg}")
|
logger.info(s"Received inv=${invMsg}")
|
||||||
val getData = GetDataMessage(invMsg.inventories.map {
|
val getData = GetDataMessage(invMsg.inventories.flatMap {
|
||||||
case Inventory(TypeIdentifier.MsgBlock, hash) =>
|
case Inventory(TypeIdentifier.MsgBlock, hash) =>
|
||||||
// only request the merkle block if we are spv enabled
|
// only request the merkle block if we are spv enabled
|
||||||
appConfig.nodeType match {
|
appConfig.nodeType match {
|
||||||
case NodeType.SpvNode =>
|
case NodeType.SpvNode =>
|
||||||
Inventory(TypeIdentifier.MsgFilteredBlock, hash)
|
Some(Inventory(TypeIdentifier.MsgFilteredBlock, hash))
|
||||||
case NodeType.NeutrinoNode | NodeType.FullNode =>
|
case NodeType.NeutrinoNode | NodeType.FullNode =>
|
||||||
Inventory(TypeIdentifier.MsgWitnessBlock, hash)
|
if (syncing) None
|
||||||
|
else Some(Inventory(TypeIdentifier.MsgWitnessBlock, hash))
|
||||||
case NodeType.BitcoindBackend =>
|
case NodeType.BitcoindBackend =>
|
||||||
throw new RuntimeException("This is impossible")
|
throw new RuntimeException("This is impossible")
|
||||||
}
|
}
|
||||||
case other: Inventory => other
|
case other: Inventory => Some(other)
|
||||||
})
|
})
|
||||||
peerMsgSender.sendMsg(getData).map(_ => this)
|
peerMsgSender.sendMsg(getData).map(_ => this)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user