Skip to content

Commit

Permalink
[FAB-9221] - check before gossip in blocks delivery
Browse files Browse the repository at this point in the history
also fixed capitalized error messages.

Change-Id: If6c7e71fb33f84f8fb29e146ad634f65818379c5
Signed-off-by: nirro <[email protected]>
  • Loading branch information
nirrozenbaum authored and C0rWin committed May 16, 2018
1 parent 9e9090e commit ff315ed
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion core/deliverservice/blocksprovider/blocksprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ func (b *blocksProviderImpl) DeliverBlocks() {

// Gossip messages with other nodes
logger.Debugf("[%s] Gossiping block [%d], peers number [%d]", b.chainID, seqNum, numberOfPeers)
b.gossip.Gossip(gossipMsg)
if !b.isDone() {
b.gossip.Gossip(gossipMsg)
}
default:
logger.Warningf("[%s] Received unknown: ", b.chainID, t)
return
Expand Down
4 changes: 2 additions & 2 deletions core/deliverservice/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func (bc *broadcastClient) try(action func() (interface{}, error)) (interface{},
return resp, nil
}
if bc.shouldStop() {
return nil, errors.New("Client is closing")
return nil, errors.New("client is closing")
}
return nil, fmt.Errorf("Attempts (%d) or elapsed time (%v) exhausted", attempt, totalRetryTime)
return nil, fmt.Errorf("attempts (%d) or elapsed time (%v) exhausted", attempt, totalRetryTime)
}

func (bc *broadcastClient) doAction(action func() (interface{}, error)) (interface{}, error) {
Expand Down
2 changes: 1 addition & 1 deletion core/deliverservice/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func TestCloseWhileRecv(t *testing.T) {
assert.Equal(t, int32(1), atomic.LoadInt32(&flag), "Recv returned before bc.Close() was called")
assert.Nil(t, resp)
assert.Error(t, err)
assert.Contains(t, "Client is closing", err.Error())
assert.Contains(t, "client is closing", err.Error())
}

func TestCloseWhileSleep(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions core/deliverservice/deliveryclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ func (d *deliverServiceImpl) UpdateEndpoints(chainID string, endpoints []string)
func (d *deliverServiceImpl) validateConfiguration() error {
conf := d.conf
if len(conf.Endpoints) == 0 {
return errors.New("No endpoints specified")
return errors.New("no endpoints specified")
}
if conf.Gossip == nil {
return errors.New("No gossip provider specified")
return errors.New("no gossip provider specified")
}
if conf.ABCFactory == nil {
return errors.New("No AtomicBroadcast factory specified")
return errors.New("no AtomicBroadcast factory specified")
}
if conf.ConnFactory == nil {
return errors.New("No connection factory specified")
return errors.New("no connection factory specified")
}
if conf.CryptoSvc == nil {
return errors.New("No crypto service specified")
return errors.New("no crypto service specified")
}
return nil
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func DefaultConnectionFactory(channelID string) func(endpoint string) (*grpc.Cli
if viper.GetBool("peer.tls.enabled") {
creds, err := comm.GetCredentialSupport().GetDeliverServiceCredentials(channelID)
if err != nil {
return nil, fmt.Errorf("Failed obtaining credentials for channel %s: %v", channelID, err)
return nil, fmt.Errorf("failed obtaining credentials for channel %s: %v", channelID, err)
}
dialOpts = append(dialOpts, grpc.WithTransportCredentials(creds))
} else {
Expand Down

0 comments on commit ff315ed

Please sign in to comment.