Remove PeerManager.{getPeerMessageSender(), getPeerConnection()}, use NodeState.{getPeerMessageSender(), getPeerConnection()} (#5400)

This commit is contained in:
Chris Stewart 2024-02-17 07:37:50 -06:00 committed by GitHub
parent e4fbfe73e6
commit f5087c5e3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,7 +72,7 @@ case class PeerManager(
nodeState: SyncNodeState)(implicit
chainAppConfig: ChainAppConfig): Future[Unit] = {
val syncPeer = nodeState.syncPeer
val peerMsgSender = getPeerMsgSender(syncPeer) match {
val peerMsgSender = nodeState.getPeerMsgSender(syncPeer) match {
case Some(p) => p
case None =>
sys.error(s"Could not find peer=$syncPeer")
@ -108,18 +108,6 @@ case class PeerManager(
}
}
private def getPeerConnection(peer: Peer): Option[PeerConnection] = {
_peerDataMap.find(_._1 == peer).map(_._2.peerConnection) match {
case Some(peerConnection) => Some(peerConnection)
case None => None
}
}
private def getPeerMsgSender(peer: Peer): Option[PeerMessageSender] = {
val randomPeerOpt = getPeerConnection(peer)
randomPeerOpt.map(PeerMessageSender(_))
}
private def createInDb(
peer: Peer,
serviceIdentifier: ServiceIdentifier): Future[PeerDb] = {
@ -1032,7 +1020,7 @@ case class PeerManager(
nodeState match {
case fhs: FilterHeaderSync =>
val peerMsgSender =
getPeerMsgSender(fhs.syncPeer).get //check this .get
nodeState.getPeerMsgSender(fhs.syncPeer).get
PeerManager
.sendFirstGetCompactFilterHeadersCommand(
peerMessageSenderApi = peerMsgSender,