Skip to content

Commit 493aee9

Browse files
committed
[FAB-5848] Identity Pull formatting
This change set makes identity digests be printed not in gibberish This is how they are printed with this patch: [gossip/pull] SendDigest -> DEBU f38 Sending IDENTITY_MSG digest: \ [67a915badc8a2f9652aeb4c09463adf706d79e0f5393233c6473bee165ee4571 \ 84ce9658381b0208178b4ee67b5267605f1641a448d3dd1401cb224aa1ec6f6e \ 5a4ec05179d9bafceb546432f7458995c92c42c6fdc10fa0fdefe449c1b46eba \ a74e91e5ea97f87f9f95c0c455963ac5e9dc73a7f99154613e1c17dc7c31fbf1] \ to 172.20.0.4:7051 [90 78 192 81 121 217 186 252 235 84 100 50 247\ 69 137 149 201 44 66 198 253 193 15 160 253 239 228 73 193 180 110 186] Change-Id: I32192cce7fd67921328c10345263e661eaa8f296 Signed-off-by: yacovm <yacovm@il.ibm.com>
1 parent 115d9c0 commit 493aee9

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

gossip/gossip/pull/pullstore.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ func (p *pullMediatorImpl) SendDigest(digest []string, nonce uint64, context int
276276
},
277277
}
278278
remotePeer := context.(proto.ReceivedMessage).GetConnectionInfo()
279-
p.logger.Debug("Sending", p.config.MsgType, "digest:", digMsg.GetDataDig().Digests, "to", remotePeer)
279+
if p.logger.IsEnabledFor(logging.DEBUG) {
280+
p.logger.Debug("Sending", p.config.MsgType, "digest:", digMsg.GetDataDig().FormattedDigests(), "to", remotePeer)
281+
}
282+
280283
context.(proto.ReceivedMessage).Respond(digMsg)
281284
}
282285

@@ -295,7 +298,9 @@ func (p *pullMediatorImpl) SendReq(dest string, items []string, nonce uint64) {
295298
},
296299
},
297300
}
298-
p.logger.Debug("Sending", req, "to", dest)
301+
if p.logger.IsEnabledFor(logging.DEBUG) {
302+
p.logger.Debug("Sending", req.GetDataReq().FormattedDigests(), "to", dest)
303+
}
299304
sMsg, err := req.NoopSign()
300305
if err != nil {
301306
p.logger.Warning("Failed creating SignedGossipMessage:", err)

protos/gossip/extensions.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package gossip
1818

1919
import (
2020
"bytes"
21+
"encoding/hex"
2122
"errors"
2223
"fmt"
2324

@@ -542,6 +543,28 @@ func (m *SignedGossipMessage) String() string {
542543
return fmt.Sprintf("GossipMessage: %v, Envelope: %s", gMsg, env)
543544
}
544545

546+
func (dd *DataRequest) FormattedDigests() []string {
547+
if dd.MsgType == PullMsgType_IDENTITY_MSG {
548+
return digestsToHex(dd.Digests)
549+
}
550+
return dd.Digests
551+
}
552+
553+
func (dd *DataDigest) FormattedDigests() []string {
554+
if dd.MsgType == PullMsgType_IDENTITY_MSG {
555+
return digestsToHex(dd.Digests)
556+
}
557+
return dd.Digests
558+
}
559+
560+
func digestsToHex(digests []string) []string {
561+
a := make([]string, len(digests))
562+
for i, dig := range digests {
563+
a[i] = hex.EncodeToString([]byte(dig))
564+
}
565+
return a
566+
}
567+
545568
// Abs returns abs(a-b)
546569
func abs(a, b uint64) uint64 {
547570
if a > b {

0 commit comments

Comments
 (0)