Skip to content

Commit

Permalink
[FAB-4005] Add channel name to logs of blocks provider
Browse files Browse the repository at this point in the history
In case there are problems with fetching blocks it's not clear
to which channel it corresponds to:

[2017-05-18 07:51:03.230 EDT [blocksProvider] DeliverBlocks -> \
 WARN 046ESC[0m Got error &{FORBIDDEN}

I added the channel name to some logging invocations

Change-Id: If04782e1c847662dfc96c4c137ec54ae5ca01f92
Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed May 21, 2017
1 parent eaf7f4d commit 5759ee4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions core/deliverservice/blocksprovider/blocksprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,26 @@ func (b *blocksProviderImpl) DeliverBlocks() {
for !b.isDone() {
msg, err := b.client.Recv()
if err != nil {
logger.Warningf("Receive error: %s", err.Error())
logger.Warningf("[%s] Receive error: %s", b.chainID, err.Error())
return
}
switch t := msg.Type.(type) {
case *orderer.DeliverResponse_Status:
if t.Status == common.Status_SUCCESS {
logger.Warning("ERROR! Received success for a seek that should never complete")
logger.Warningf("[%s] ERROR! Received success for a seek that should never complete", b.chainID)
return
}
logger.Warning("Got error ", t)
logger.Warningf("[%s] Got error %v", b.chainID, t)
case *orderer.DeliverResponse_Block:
seqNum := t.Block.Header.Number

marshaledBlock, err := proto.Marshal(t.Block)
if err != nil {
logger.Errorf("Error serializing block with sequence number %d, due to %s", seqNum, err)
logger.Errorf("[%s] Error serializing block with sequence number %d, due to %s", b.chainID, seqNum, err)
continue
}
if err := b.mcs.VerifyBlock(gossipcommon.ChainID(b.chainID), seqNum, marshaledBlock); err != nil {
logger.Errorf("Error verifying block with sequnce number %d, due to %s", seqNum, err)
logger.Errorf("[%s] Error verifying block with sequnce number %d, due to %s", b.chainID, seqNum, err)
continue
}

Expand All @@ -146,15 +146,15 @@ func (b *blocksProviderImpl) DeliverBlocks() {
// Use payload to create gossip message
gossipMsg := createGossipMsg(b.chainID, payload)

logger.Debugf("Adding payload locally, buffer seqNum = [%d], peers number [%d]", seqNum, numberOfPeers)
logger.Debugf("[%s] Adding payload locally, buffer seqNum = [%d], peers number [%d]", b.chainID, seqNum, numberOfPeers)
// Add payload to local state payloads buffer
b.gossip.AddPayload(b.chainID, payload)

// Gossip messages with other nodes
logger.Debugf("Gossiping block [%d], peers number [%d]", seqNum, numberOfPeers)
logger.Debugf("[%s] Gossiping block [%d], peers number [%d]", b.chainID, seqNum, numberOfPeers)
b.gossip.Gossip(gossipMsg)
default:
logger.Warning("Received unknown: ", t)
logger.Warningf("[%s] Received unknown: ", b.chainID, t)
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/deliverservice/deliveryclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (d *deliverServiceImpl) StartDeliverForChannel(chainID string, ledgerInfo b
return errors.New(errMsg)
} else {
client := d.newClient(chainID, ledgerInfo)
logger.Debug("This peer will pass blocks from orderer service to other peers")
logger.Debug("This peer will pass blocks from orderer service to other peers for channel", chainID)
d.blockProviders[chainID] = blocksprovider.NewBlocksProvider(chainID, client, d.conf.Gossip, d.conf.CryptoSvc)
go d.blockProviders[chainID].DeliverBlocks()
}
Expand Down
6 changes: 3 additions & 3 deletions core/deliverservice/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ type blocksRequester struct {
func (b *blocksRequester) RequestBlocks(ledgerInfoProvider blocksprovider.LedgerInfo) error {
height, err := ledgerInfoProvider.LedgerHeight()
if err != nil {
logger.Errorf("Can't get legder height from committer [%s]", err)
logger.Errorf("Can't get legder height for channel %s from committer [%s]", b.chainID, err)
return err
}

if height > 0 {
logger.Debugf("Starting deliver with block [%d]", height)
logger.Debugf("Starting deliver with block [%d] for channel %s", height, b.chainID)
if err := b.seekLatestFromCommitter(height); err != nil {
return err
}
} else {
logger.Debug("Starting deliver with olders block")
logger.Debugf("Starting deliver with olders block for channel %s", b.chainID)
if err := b.seekOldest(); err != nil {
return err
}
Expand Down

0 comments on commit 5759ee4

Please sign in to comment.