Node: don't protect from self (#3318)

This commit is contained in:
bruce-riley 2023-08-23 16:20:57 -05:00 committed by GitHub
parent e4fc44771a
commit 753185e042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 12 deletions

View File

@ -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 {