Node: don't protect from self (#3318)
This commit is contained in:
parent
e4fc44771a
commit
753185e042
|
@ -566,21 +566,23 @@ func Run(
|
|||
zap.String("from", envelope.GetFrom().String()))
|
||||
} else {
|
||||
guardianAddr := eth_common.BytesToAddress(s.GuardianAddr)
|
||||
prevPeerId, ok := components.ProtectedHostByGuardianKey[guardianAddr]
|
||||
if ok {
|
||||
if prevPeerId != peerId {
|
||||
logger.Info("p2p_guardian_peer_changed",
|
||||
zap.String("guardian_addr", guardianAddr.String()),
|
||||
zap.String("prevPeerId", prevPeerId.String()),
|
||||
zap.String("newPeerId", peerId.String()),
|
||||
)
|
||||
components.ConnMgr.Unprotect(prevPeerId, "heartbeat")
|
||||
if guardianAddr != ethcrypto.PubkeyToAddress(gk.PublicKey) {
|
||||
prevPeerId, ok := components.ProtectedHostByGuardianKey[guardianAddr]
|
||||
if ok {
|
||||
if prevPeerId != peerId {
|
||||
logger.Info("p2p_guardian_peer_changed",
|
||||
zap.String("guardian_addr", guardianAddr.String()),
|
||||
zap.String("prevPeerId", prevPeerId.String()),
|
||||
zap.String("newPeerId", peerId.String()),
|
||||
)
|
||||
components.ConnMgr.Unprotect(prevPeerId, "heartbeat")
|
||||
components.ConnMgr.Protect(peerId, "heartbeat")
|
||||
components.ProtectedHostByGuardianKey[guardianAddr] = peerId
|
||||
}
|
||||
} else {
|
||||
components.ConnMgr.Protect(peerId, "heartbeat")
|
||||
components.ProtectedHostByGuardianKey[guardianAddr] = peerId
|
||||
}
|
||||
} else {
|
||||
components.ConnMgr.Protect(peerId, "heartbeat")
|
||||
components.ProtectedHostByGuardianKey[guardianAddr] = peerId
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue