@@ -35,8 +35,6 @@ import (
35
35
"google.golang.org/grpc"
36
36
)
37
37
38
- type gossipSvc Gossip
39
-
40
38
// Gossip is the interface of the gossip component
41
39
type Gossip interface {
42
40
// SelfMembershipInfo returns the peer's membership information
@@ -106,29 +104,14 @@ type Gossip interface {
106
104
Stop ()
107
105
}
108
106
109
- // GossipService encapsulates gossip and state capabilities into single interface
110
- type GossipService interface {
111
- Gossip
112
-
113
- // DistributePrivateData distributes private data to the peers in the collections
114
- // according to policies induced by the PolicyStore and PolicyParser
115
- DistributePrivateData (channelID string , txID string , privateData * transientstore.TxPvtReadWriteSetWithConfigInfo , blkHt uint64 ) error
116
- // NewConfigEventer creates a ConfigProcessor which the channelconfig.BundleSource can ultimately route config updates to
117
- NewConfigEventer () ConfigProcessor
118
- // InitializeChannel allocates the state provider and should be invoked once per channel per execution
119
- InitializeChannel (channelID string , endpoints []string , support Support )
120
- // AddPayload appends message payload to for given chain
121
- AddPayload (channelID string , payload * gproto.Payload ) error
122
- }
123
-
124
107
// GossipServiceAdapter serves to provide basic functionality
125
108
// required from gossip service by delivery service
126
109
type GossipServiceAdapter interface {
127
110
// PeersOfChannel returns slice with members of specified channel
128
111
PeersOfChannel (gossipcommon.ChannelID ) []discovery.NetworkMember
129
112
130
113
// AddPayload adds payload to the local state sync buffer
131
- AddPayload (chainID string , payload * gproto.Payload ) error
114
+ AddPayload (channelID string , payload * gproto.Payload ) error
132
115
133
116
// Gossip the message across the peers
134
117
Gossip (msg * gproto.GossipMessage )
@@ -168,7 +151,9 @@ func (p privateHandler) close() {
168
151
p .reconciler .Stop ()
169
152
}
170
153
171
- type GossipServiceImpl struct {
154
+ type gossipSvc Gossip
155
+
156
+ type GossipService struct {
172
157
gossipSvc
173
158
privateHandlers map [string ]privateHandler
174
159
chains map [string ]state.GossipStateProvider
@@ -220,7 +205,7 @@ func New(
220
205
secAdv api.SecurityAdvisor ,
221
206
secureDialOpts api.PeerSecureDialOpts ,
222
207
bootPeers ... string ,
223
- ) (* GossipServiceImpl , error ) {
208
+ ) (* GossipService , error ) {
224
209
serializedIdentity , err := peerIdentity .Serialize ()
225
210
if err != nil {
226
211
return nil , err
@@ -247,7 +232,7 @@ func New(
247
232
gossipMetrics ,
248
233
)
249
234
250
- return & GossipServiceImpl {
235
+ return & GossipService {
251
236
gossipSvc : gossipComponent ,
252
237
mcs : mcs ,
253
238
privateHandlers : make (map [string ]privateHandler ),
@@ -263,7 +248,7 @@ func New(
263
248
}
264
249
265
250
// DistributePrivateData distribute private read write set inside the channel based on the collections policies
266
- func (g * GossipServiceImpl ) DistributePrivateData (channelID string , txID string , privData * transientstore.TxPvtReadWriteSetWithConfigInfo , blkHt uint64 ) error {
251
+ func (g * GossipService ) DistributePrivateData (channelID string , txID string , privData * transientstore.TxPvtReadWriteSetWithConfigInfo , blkHt uint64 ) error {
267
252
g .lock .RLock ()
268
253
handler , exists := g .privateHandlers [channelID ]
269
254
g .lock .RUnlock ()
@@ -285,7 +270,7 @@ func (g *GossipServiceImpl) DistributePrivateData(channelID string, txID string,
285
270
}
286
271
287
272
// NewConfigEventer creates a ConfigProcessor which the channelconfig.BundleSource can ultimately route config updates to
288
- func (g * GossipServiceImpl ) NewConfigEventer () ConfigProcessor {
273
+ func (g * GossipService ) NewConfigEventer () ConfigProcessor {
289
274
return newConfigEventer (g )
290
275
}
291
276
@@ -307,7 +292,7 @@ type DataStoreSupport struct {
307
292
}
308
293
309
294
// InitializeChannel allocates the state provider and should be invoked once per channel per execution
310
- func (g * GossipServiceImpl ) InitializeChannel (channelID string , endpoints []string , support Support ) {
295
+ func (g * GossipService ) InitializeChannel (channelID string , endpoints []string , support Support ) {
311
296
g .lock .Lock ()
312
297
defer g .lock .Unlock ()
313
298
// Initialize new state provider for given committer
@@ -401,7 +386,7 @@ func (g *GossipServiceImpl) InitializeChannel(channelID string, endpoints []stri
401
386
}
402
387
}
403
388
404
- func (g * GossipServiceImpl ) createSelfSignedData () protoutil.SignedData {
389
+ func (g * GossipService ) createSelfSignedData () protoutil.SignedData {
405
390
msg := make ([]byte , 32 )
406
391
sig , err := g .mcs .Sign (msg )
407
392
if err != nil {
@@ -415,7 +400,7 @@ func (g *GossipServiceImpl) createSelfSignedData() protoutil.SignedData {
415
400
}
416
401
417
402
// updateAnchors constructs a joinChannelMessage and sends it to the gossipSvc
418
- func (g * GossipServiceImpl ) updateAnchors (config Config ) {
403
+ func (g * GossipService ) updateAnchors (config Config ) {
419
404
myOrg := string (g .secAdv .OrgByPeerIdentity (api .PeerIdentityType (g .peerIdentity )))
420
405
if ! g .amIinChannel (myOrg , config ) {
421
406
logger .Error ("Tried joining channel" , config .ChainID (), "but our org(" , myOrg , "), isn't " +
@@ -440,7 +425,7 @@ func (g *GossipServiceImpl) updateAnchors(config Config) {
440
425
g .JoinChan (jcm , gossipcommon .ChannelID (config .ChainID ()))
441
426
}
442
427
443
- func (g * GossipServiceImpl ) updateEndpoints (channelID string , endpoints []string ) {
428
+ func (g * GossipService ) updateEndpoints (channelID string , endpoints []string ) {
444
429
if ds , ok := g .deliveryService [channelID ]; ok {
445
430
logger .Debugf ("Updating endpoints for channelID %s" , channelID )
446
431
if err := ds .UpdateEndpoints (channelID , endpoints ); err != nil {
@@ -452,14 +437,14 @@ func (g *GossipServiceImpl) updateEndpoints(channelID string, endpoints []string
452
437
}
453
438
454
439
// AddPayload appends message payload to for given chain
455
- func (g * GossipServiceImpl ) AddPayload (channelID string , payload * gproto.Payload ) error {
440
+ func (g * GossipService ) AddPayload (channelID string , payload * gproto.Payload ) error {
456
441
g .lock .RLock ()
457
442
defer g .lock .RUnlock ()
458
443
return g .chains [channelID ].AddPayload (payload )
459
444
}
460
445
461
446
// Stop stops the gossip component
462
- func (g * GossipServiceImpl ) Stop () {
447
+ func (g * GossipService ) Stop () {
463
448
g .lock .Lock ()
464
449
defer g .lock .Unlock ()
465
450
@@ -479,7 +464,7 @@ func (g *GossipServiceImpl) Stop() {
479
464
g .gossipSvc .Stop ()
480
465
}
481
466
482
- func (g * GossipServiceImpl ) newLeaderElectionComponent (channelID string , callback func (bool ),
467
+ func (g * GossipService ) newLeaderElectionComponent (channelID string , callback func (bool ),
483
468
electionMetrics * gossipmetrics.ElectionMetrics ) election.LeaderElectionService {
484
469
PKIid := g .mcs .GetPKIidOfCert (g .peerIdentity )
485
470
adapter := election .NewAdapter (g , PKIid , gossipcommon .ChannelID (channelID ), electionMetrics )
@@ -492,7 +477,7 @@ func (g *GossipServiceImpl) newLeaderElectionComponent(channelID string, callbac
492
477
return election .NewLeaderElectionService (adapter , string (PKIid ), callback , config )
493
478
}
494
479
495
- func (g * GossipServiceImpl ) amIinChannel (myOrg string , config Config ) bool {
480
+ func (g * GossipService ) amIinChannel (myOrg string , config Config ) bool {
496
481
for _ , orgName := range orgListFromConfig (config ) {
497
482
if orgName == myOrg {
498
483
return true
@@ -501,7 +486,7 @@ func (g *GossipServiceImpl) amIinChannel(myOrg string, config Config) bool {
501
486
return false
502
487
}
503
488
504
- func (g * GossipServiceImpl ) onStatusChangeFactory (channelID string , committer blocksprovider.LedgerInfo ) func (bool ) {
489
+ func (g * GossipService ) onStatusChangeFactory (channelID string , committer blocksprovider.LedgerInfo ) func (bool ) {
505
490
return func (isLeader bool ) {
506
491
if isLeader {
507
492
yield := func () {
0 commit comments