Skip to content

Commit 6cd02a6

Browse files
committed
[FAB-17095] MCS not to print identities as bytes
The messageCryptoService prints identities as decimal bytes, and this doesn't help much with debugging because no sane person would want to convert a decimal byte array to a PEM manually and then pass it through openssl to figure out what is the peer in question. This change set makes the logs use the String() method of the PeerIdentityType. Change-Id: I71706d6d941de3a9fe7d6efbadf28949142232e2 Signed-off-by: yacovm <yacovm@il.ibm.com>
1 parent 0cd1107 commit 6cd02a6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/peer/gossip/mcs.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (s *MSPMessageCryptoService) GetPKIidOfCert(peerIdentity api.PeerIdentityTy
9696

9797
sid, err := s.deserializer.Deserialize(peerIdentity)
9898
if err != nil {
99-
mcsLogger.Errorf("Failed getting validated identity from peer identity [% x]: [%s]", peerIdentity, err)
99+
mcsLogger.Errorf("Failed getting validated identity from peer identity %s: [%s]", peerIdentity, err)
100100

101101
return nil
102102
}
@@ -111,7 +111,7 @@ func (s *MSPMessageCryptoService) GetPKIidOfCert(peerIdentity api.PeerIdentityTy
111111
// Hash
112112
digest, err := s.hasher.Hash(raw, &bccsp.SHA256Opts{})
113113
if err != nil {
114-
mcsLogger.Errorf("Failed computing digest of serialized identity [% x]: [%s]", peerIdentity, err)
114+
mcsLogger.Errorf("Failed computing digest of serialized identity %s: [%s]", peerIdentity, err)
115115
return nil
116116
}
117117

@@ -312,7 +312,7 @@ func (s *MSPMessageCryptoService) getValidatedIdentity(peerIdentity api.PeerIden
312312
// Deserialize identity
313313
identity, err := mspManager.DeserializeIdentity([]byte(peerIdentity))
314314
if err != nil {
315-
mcsLogger.Debugf("Failed deserialization identity [% x] on [%s]: [%s]", peerIdentity, chainID, err)
315+
mcsLogger.Debugf("Failed deserialization identity %s on [%s]: [%s]", peerIdentity, chainID, err)
316316
continue
317317
}
318318

@@ -327,14 +327,14 @@ func (s *MSPMessageCryptoService) getValidatedIdentity(peerIdentity api.PeerIden
327327
// This will be done by the caller function, if needed.
328328

329329
if err := identity.Validate(); err != nil {
330-
mcsLogger.Debugf("Failed validating identity [% x] on [%s]: [%s]", peerIdentity, chainID, err)
330+
mcsLogger.Debugf("Failed validating identity %s on [%s]: [%s]", peerIdentity, chainID, err)
331331
continue
332332
}
333333

334-
mcsLogger.Debugf("Validation succeeded [% x] on [%s]", peerIdentity, chainID)
334+
mcsLogger.Debugf("Validation succeeded %s on [%s]", peerIdentity, chainID)
335335

336336
return identity, common.ChannelID(chainID), nil
337337
}
338338

339-
return nil, nil, fmt.Errorf("Peer Identity [% x] cannot be validated. No MSP found able to do that.", peerIdentity)
339+
return nil, nil, fmt.Errorf("Peer Identity %s cannot be validated. No MSP found able to do that.", peerIdentity)
340340
}

0 commit comments

Comments
 (0)