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()))
|
zap.String("from", envelope.GetFrom().String()))
|
||||||
} else {
|
} else {
|
||||||
guardianAddr := eth_common.BytesToAddress(s.GuardianAddr)
|
guardianAddr := eth_common.BytesToAddress(s.GuardianAddr)
|
||||||
prevPeerId, ok := components.ProtectedHostByGuardianKey[guardianAddr]
|
if guardianAddr != ethcrypto.PubkeyToAddress(gk.PublicKey) {
|
||||||
if ok {
|
prevPeerId, ok := components.ProtectedHostByGuardianKey[guardianAddr]
|
||||||
if prevPeerId != peerId {
|
if ok {
|
||||||
logger.Info("p2p_guardian_peer_changed",
|
if prevPeerId != peerId {
|
||||||
zap.String("guardian_addr", guardianAddr.String()),
|
logger.Info("p2p_guardian_peer_changed",
|
||||||
zap.String("prevPeerId", prevPeerId.String()),
|
zap.String("guardian_addr", guardianAddr.String()),
|
||||||
zap.String("newPeerId", peerId.String()),
|
zap.String("prevPeerId", prevPeerId.String()),
|
||||||
)
|
zap.String("newPeerId", peerId.String()),
|
||||||
components.ConnMgr.Unprotect(prevPeerId, "heartbeat")
|
)
|
||||||
|
components.ConnMgr.Unprotect(prevPeerId, "heartbeat")
|
||||||
|
components.ConnMgr.Protect(peerId, "heartbeat")
|
||||||
|
components.ProtectedHostByGuardianKey[guardianAddr] = peerId
|
||||||
|
}
|
||||||
|
} else {
|
||||||
components.ConnMgr.Protect(peerId, "heartbeat")
|
components.ConnMgr.Protect(peerId, "heartbeat")
|
||||||
components.ProtectedHostByGuardianKey[guardianAddr] = peerId
|
components.ProtectedHostByGuardianKey[guardianAddr] = peerId
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
components.ConnMgr.Protect(peerId, "heartbeat")
|
|
||||||
components.ProtectedHostByGuardianKey[guardianAddr] = peerId
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue