server: Use local addr var in version handler.
This modifies the OnVersion handler for server peers to use a local variable for the remote address of the peer in order to avoid grabbing the mutex multiple times. There are no functional changes. Backported from Decred.
This commit is contained in:
parent
c8b9fab820
commit
8c981e4ef2
1 changed files with 4 additions and 3 deletions
|
@ -406,9 +406,10 @@ func (sp *serverPeer) OnVersion(_ *peer.Peer, msg *wire.MsgVersion) *wire.MsgRej
|
|||
// it is updated regardless in the case a new minimum protocol version is
|
||||
// enforced and the remote node has not upgraded yet.
|
||||
isInbound := sp.Inbound()
|
||||
remoteAddr := sp.NA()
|
||||
addrManager := sp.server.addrManager
|
||||
if !cfg.SimNet && !isInbound {
|
||||
addrManager.SetServices(sp.NA(), msg.Services)
|
||||
addrManager.SetServices(remoteAddr, msg.Services)
|
||||
}
|
||||
|
||||
// Ignore peers that have a protcol version that is too old. The peer
|
||||
|
@ -457,7 +458,7 @@ func (sp *serverPeer) OnVersion(_ *peer.Peer, msg *wire.MsgVersion) *wire.MsgRej
|
|||
// connections and it believes itself to be close to the best known tip.
|
||||
if !cfg.DisableListen && sp.server.syncManager.IsCurrent() {
|
||||
// Get address that best matches.
|
||||
lna := addrManager.GetBestLocalAddress(sp.NA())
|
||||
lna := addrManager.GetBestLocalAddress(remoteAddr)
|
||||
if addrmgr.IsRoutable(lna) {
|
||||
// Filter addresses the peer already knows about.
|
||||
addresses := []*wire.NetAddress{lna}
|
||||
|
@ -474,7 +475,7 @@ func (sp *serverPeer) OnVersion(_ *peer.Peer, msg *wire.MsgVersion) *wire.MsgRej
|
|||
}
|
||||
|
||||
// Mark the address as a known good address.
|
||||
addrManager.Good(sp.NA())
|
||||
addrManager.Good(remoteAddr)
|
||||
}
|
||||
|
||||
// Add the remote peer time as a sample for creating an offset against
|
||||
|
|
Loading…
Reference in a new issue