Skip to content

Commit ff315ed

Browse files
nirrozenbaumC0rWin
authored andcommitted
[FAB-9221] - check before gossip in blocks delivery
also fixed capitalized error messages. Change-Id: If6c7e71fb33f84f8fb29e146ad634f65818379c5 Signed-off-by: nirro <nirro@il.ibm.com>
1 parent 9e9090e commit ff315ed

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

core/deliverservice/blocksprovider/blocksprovider.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ func (b *blocksProviderImpl) DeliverBlocks() {
191191

192192
// Gossip messages with other nodes
193193
logger.Debugf("[%s] Gossiping block [%d], peers number [%d]", b.chainID, seqNum, numberOfPeers)
194-
b.gossip.Gossip(gossipMsg)
194+
if !b.isDone() {
195+
b.gossip.Gossip(gossipMsg)
196+
}
195197
default:
196198
logger.Warningf("[%s] Received unknown: ", b.chainID, t)
197199
return

core/deliverservice/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func (bc *broadcastClient) try(action func() (interface{}, error)) (interface{},
100100
return resp, nil
101101
}
102102
if bc.shouldStop() {
103-
return nil, errors.New("Client is closing")
103+
return nil, errors.New("client is closing")
104104
}
105-
return nil, fmt.Errorf("Attempts (%d) or elapsed time (%v) exhausted", attempt, totalRetryTime)
105+
return nil, fmt.Errorf("attempts (%d) or elapsed time (%v) exhausted", attempt, totalRetryTime)
106106
}
107107

108108
func (bc *broadcastClient) doAction(action func() (interface{}, error)) (interface{}, error) {

core/deliverservice/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ func TestCloseWhileRecv(t *testing.T) {
516516
assert.Equal(t, int32(1), atomic.LoadInt32(&flag), "Recv returned before bc.Close() was called")
517517
assert.Nil(t, resp)
518518
assert.Error(t, err)
519-
assert.Contains(t, "Client is closing", err.Error())
519+
assert.Contains(t, "client is closing", err.Error())
520520
}
521521

522522
func TestCloseWhileSleep(t *testing.T) {

core/deliverservice/deliveryclient.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,19 @@ func (d *deliverServiceImpl) UpdateEndpoints(chainID string, endpoints []string)
126126
func (d *deliverServiceImpl) validateConfiguration() error {
127127
conf := d.conf
128128
if len(conf.Endpoints) == 0 {
129-
return errors.New("No endpoints specified")
129+
return errors.New("no endpoints specified")
130130
}
131131
if conf.Gossip == nil {
132-
return errors.New("No gossip provider specified")
132+
return errors.New("no gossip provider specified")
133133
}
134134
if conf.ABCFactory == nil {
135-
return errors.New("No AtomicBroadcast factory specified")
135+
return errors.New("no AtomicBroadcast factory specified")
136136
}
137137
if conf.ConnFactory == nil {
138-
return errors.New("No connection factory specified")
138+
return errors.New("no connection factory specified")
139139
}
140140
if conf.CryptoSvc == nil {
141-
return errors.New("No crypto service specified")
141+
return errors.New("no crypto service specified")
142142
}
143143
return nil
144144
}
@@ -256,7 +256,7 @@ func DefaultConnectionFactory(channelID string) func(endpoint string) (*grpc.Cli
256256
if viper.GetBool("peer.tls.enabled") {
257257
creds, err := comm.GetCredentialSupport().GetDeliverServiceCredentials(channelID)
258258
if err != nil {
259-
return nil, fmt.Errorf("Failed obtaining credentials for channel %s: %v", channelID, err)
259+
return nil, fmt.Errorf("failed obtaining credentials for channel %s: %v", channelID, err)
260260
}
261261
dialOpts = append(dialOpts, grpc.WithTransportCredentials(creds))
262262
} else {

0 commit comments

Comments
 (0)