[ping] display blskey in ping message

Signed-off-by: Leo Chen <leo@harmony.one>
pull/1428/head
Leo Chen 5 years ago
parent dc040999a6
commit 591c6fbece
  1. 2
      api/service/discovery/service.go
  2. 33
      node/node_handler.go
  3. 1
      p2p/host/hostv2/hostv2.go
  4. 1
      p2p/p2pimpl/p2pimpl.go

@ -85,7 +85,6 @@ func (s *Service) contactP2pPeers() {
msgBuf := host.ConstructP2pMessage(byte(0), pingMsg.ConstructPingMessage())
s.sentPingMessage(s.config.ShardGroupID, msgBuf)
utils.Logger().Info().Interface("[PING]", pingMsg).Msg("Sent Ping Message")
for {
select {
@ -106,7 +105,6 @@ func (s *Service) contactP2pPeers() {
}
s.sentPingMessage(s.config.ShardGroupID, msgBuf)
utils.Logger().Info().Interface("[PING]", pingMsg).Msg("Sent Ping Message")
// the longest sleep is 3600 seconds
if pingInterval >= 3600 {

@ -724,20 +724,6 @@ func (node *Node) pingMessageHandler(msgPayload []byte, sender libp2p_peer.ID) i
peer.PeerID = ping.Node.PeerID
peer.ConsensusPubKey = nil
utils.Logger().Info().
Str("Peer Version", ping.NodeVer).
Interface("PeerID", peer).
Msg("[PING] received ping message")
senderStr := string(sender)
if senderStr != "" {
_, ok := node.duplicatedPing.LoadOrStore(senderStr, true)
if ok {
// duplicated ping message return
return 0
}
}
if ping.Node.PubKey != nil {
peer.ConsensusPubKey = &bls.PublicKey{}
if err := peer.ConsensusPubKey.Deserialize(ping.Node.PubKey[:]); err != nil {
@ -748,10 +734,21 @@ func (node *Node) pingMessageHandler(msgPayload []byte, sender libp2p_peer.ID) i
}
}
var k types.BlsPublicKey
if err := k.FromLibBLSPublicKey(peer.ConsensusPubKey); err != nil {
err = ctxerror.New("cannot convert BLS public key").WithCause(err)
ctxerror.Log15(utils.GetLogger().Warn, err)
utils.Logger().Info().
Str("Version", ping.NodeVer).
Str("BlsKey", peer.ConsensusPubKey.SerializeToHexStr()).
Str("IP", peer.IP).
Str("Port", peer.Port).
Interface("PeerID", peer.PeerID).
Msg("[PING] PeerInfo")
senderStr := string(sender)
if senderStr != "" {
_, ok := node.duplicatedPing.LoadOrStore(senderStr, true)
if ok {
// duplicated ping message return
return 0
}
}
// add to incoming peer list

@ -189,6 +189,7 @@ func New(self *p2p.Peer, priKey libp2p_crypto.PrivKey) *HostV2 {
Str("port", self.Port).
Str("id", p2pHost.ID().Pretty()).
Str("addr", listenAddr.String()).
Str("PubKey", self.ConsensusPubKey.SerializeToHexStr()).
Msg("HostV2 is up!")
return h

@ -19,6 +19,7 @@ func NewHost(self *p2p.Peer, key libp2p_crypto.PrivKey) (p2p.Host, error) {
utils.Logger().Info().
Str("self", net.JoinHostPort(self.IP, self.Port)).
Interface("PeerID", self.PeerID).
Str("PubKey", self.ConsensusPubKey.SerializeToHexStr()).
Msg("NewHost")
return h, nil

Loading…
Cancel
Save