Only log a warning instead of throwing an exception when we try to send a message to a peer we aren't connected to (#5161)

This commit is contained in:
Chris Stewart 2023-07-25 09:34:14 -05:00 committed by GitHub
parent 092ef944e2
commit 4afaaf8f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,10 +124,7 @@ case class PeerManager(
.map(_.peerMessageSender)
case _: DataPayload =>
//peer must be fully initialized to send a data payload
val msg =
s"Cannot find peerOpt=${sendToPeer.peerOpt} to send message=${sendToPeer.msg.payload.commandName} to. It may have been disconnected, sending to another random peer."
logger.warn(msg)
randomPeerMsgSenderWithService(ServiceIdentifier.NODE_NETWORK)
None
}
}
case None =>
@ -139,8 +136,10 @@ case class PeerManager(
peerMsgSender
.sendMsg(sendToPeer.msg)
case None =>
sys.error(
s"Unable to find peer message sender to send msg=${sendToPeer.msg.header.commandName} to. This means we are not connected to any peers.")
val msg =
s"Cannot find peerOpt=${sendToPeer.peerOpt} in set of peers=$peers to send message=${sendToPeer.msg.payload.commandName} to. It may have been disconnected, or we have no peers."
logger.warn(msg)
Future.unit
}
}