Skip to content

Commit dc182a6

Browse files
committed
[FAB-14324] rename GossipServiceImpl GossipService
Change-Id: I78b2c65944c057e13eba618be54918ff24d77be4 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent e26ceaa commit dc182a6

File tree

6 files changed

+31
-46
lines changed

6 files changed

+31
-46
lines changed

core/peer/peer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ type Peer struct {
416416
storesMutex sync.RWMutex
417417
stores map[string]transientstore.Store
418418

419-
GossipService gossipservice.GossipService
419+
GossipService *gossipservice.GossipService
420420

421421
// validationWorkersSemaphore is used to limit the number of concurrent validation
422422
// go routines.

gossip/service/gossip_service.go

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import (
3535
"google.golang.org/grpc"
3636
)
3737

38-
type gossipSvc Gossip
39-
4038
// Gossip is the interface of the gossip component
4139
type Gossip interface {
4240
// SelfMembershipInfo returns the peer's membership information
@@ -106,29 +104,14 @@ type Gossip interface {
106104
Stop()
107105
}
108106

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-
124107
// GossipServiceAdapter serves to provide basic functionality
125108
// required from gossip service by delivery service
126109
type GossipServiceAdapter interface {
127110
// PeersOfChannel returns slice with members of specified channel
128111
PeersOfChannel(gossipcommon.ChannelID) []discovery.NetworkMember
129112

130113
// 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
132115

133116
// Gossip the message across the peers
134117
Gossip(msg *gproto.GossipMessage)
@@ -168,7 +151,9 @@ func (p privateHandler) close() {
168151
p.reconciler.Stop()
169152
}
170153

171-
type GossipServiceImpl struct {
154+
type gossipSvc Gossip
155+
156+
type GossipService struct {
172157
gossipSvc
173158
privateHandlers map[string]privateHandler
174159
chains map[string]state.GossipStateProvider
@@ -220,7 +205,7 @@ func New(
220205
secAdv api.SecurityAdvisor,
221206
secureDialOpts api.PeerSecureDialOpts,
222207
bootPeers ...string,
223-
) (*GossipServiceImpl, error) {
208+
) (*GossipService, error) {
224209
serializedIdentity, err := peerIdentity.Serialize()
225210
if err != nil {
226211
return nil, err
@@ -247,7 +232,7 @@ func New(
247232
gossipMetrics,
248233
)
249234

250-
return &GossipServiceImpl{
235+
return &GossipService{
251236
gossipSvc: gossipComponent,
252237
mcs: mcs,
253238
privateHandlers: make(map[string]privateHandler),
@@ -263,7 +248,7 @@ func New(
263248
}
264249

265250
// 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 {
267252
g.lock.RLock()
268253
handler, exists := g.privateHandlers[channelID]
269254
g.lock.RUnlock()
@@ -285,7 +270,7 @@ func (g *GossipServiceImpl) DistributePrivateData(channelID string, txID string,
285270
}
286271

287272
// 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 {
289274
return newConfigEventer(g)
290275
}
291276

@@ -307,7 +292,7 @@ type DataStoreSupport struct {
307292
}
308293

309294
// 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) {
311296
g.lock.Lock()
312297
defer g.lock.Unlock()
313298
// Initialize new state provider for given committer
@@ -401,7 +386,7 @@ func (g *GossipServiceImpl) InitializeChannel(channelID string, endpoints []stri
401386
}
402387
}
403388

404-
func (g *GossipServiceImpl) createSelfSignedData() protoutil.SignedData {
389+
func (g *GossipService) createSelfSignedData() protoutil.SignedData {
405390
msg := make([]byte, 32)
406391
sig, err := g.mcs.Sign(msg)
407392
if err != nil {
@@ -415,7 +400,7 @@ func (g *GossipServiceImpl) createSelfSignedData() protoutil.SignedData {
415400
}
416401

417402
// updateAnchors constructs a joinChannelMessage and sends it to the gossipSvc
418-
func (g *GossipServiceImpl) updateAnchors(config Config) {
403+
func (g *GossipService) updateAnchors(config Config) {
419404
myOrg := string(g.secAdv.OrgByPeerIdentity(api.PeerIdentityType(g.peerIdentity)))
420405
if !g.amIinChannel(myOrg, config) {
421406
logger.Error("Tried joining channel", config.ChainID(), "but our org(", myOrg, "), isn't "+
@@ -440,7 +425,7 @@ func (g *GossipServiceImpl) updateAnchors(config Config) {
440425
g.JoinChan(jcm, gossipcommon.ChannelID(config.ChainID()))
441426
}
442427

443-
func (g *GossipServiceImpl) updateEndpoints(channelID string, endpoints []string) {
428+
func (g *GossipService) updateEndpoints(channelID string, endpoints []string) {
444429
if ds, ok := g.deliveryService[channelID]; ok {
445430
logger.Debugf("Updating endpoints for channelID %s", channelID)
446431
if err := ds.UpdateEndpoints(channelID, endpoints); err != nil {
@@ -452,14 +437,14 @@ func (g *GossipServiceImpl) updateEndpoints(channelID string, endpoints []string
452437
}
453438

454439
// 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 {
456441
g.lock.RLock()
457442
defer g.lock.RUnlock()
458443
return g.chains[channelID].AddPayload(payload)
459444
}
460445

461446
// Stop stops the gossip component
462-
func (g *GossipServiceImpl) Stop() {
447+
func (g *GossipService) Stop() {
463448
g.lock.Lock()
464449
defer g.lock.Unlock()
465450

@@ -479,7 +464,7 @@ func (g *GossipServiceImpl) Stop() {
479464
g.gossipSvc.Stop()
480465
}
481466

482-
func (g *GossipServiceImpl) newLeaderElectionComponent(channelID string, callback func(bool),
467+
func (g *GossipService) newLeaderElectionComponent(channelID string, callback func(bool),
483468
electionMetrics *gossipmetrics.ElectionMetrics) election.LeaderElectionService {
484469
PKIid := g.mcs.GetPKIidOfCert(g.peerIdentity)
485470
adapter := election.NewAdapter(g, PKIid, gossipcommon.ChannelID(channelID), electionMetrics)
@@ -492,7 +477,7 @@ func (g *GossipServiceImpl) newLeaderElectionComponent(channelID string, callbac
492477
return election.NewLeaderElectionService(adapter, string(PKIid), callback, config)
493478
}
494479

495-
func (g *GossipServiceImpl) amIinChannel(myOrg string, config Config) bool {
480+
func (g *GossipService) amIinChannel(myOrg string, config Config) bool {
496481
for _, orgName := range orgListFromConfig(config) {
497482
if orgName == myOrg {
498483
return true
@@ -501,7 +486,7 @@ func (g *GossipServiceImpl) amIinChannel(myOrg string, config Config) bool {
501486
return false
502487
}
503488

504-
func (g *GossipServiceImpl) onStatusChangeFactory(channelID string, committer blocksprovider.LedgerInfo) func(bool) {
489+
func (g *GossipService) onStatusChangeFactory(channelID string, committer blocksprovider.LedgerInfo) func(bool) {
505490
return func(isLeader bool) {
506491
if isLeader {
507492
yield := func() {

gossip/service/gossip_service_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,10 @@ func stopPeers(peers []*gossipGRPC) {
646646
stoppingWg := sync.WaitGroup{}
647647
stoppingWg.Add(len(peers))
648648
for i, pI := range peers {
649-
go func(i int, p_i *GossipServiceImpl) {
649+
go func(i int, p_i *GossipService) {
650650
defer stoppingWg.Done()
651651
p_i.Stop()
652-
}(i, pI.GossipServiceImpl)
652+
}(i, pI.GossipService)
653653
}
654654
stoppingWg.Wait()
655655
time.Sleep(time.Second * time.Duration(2))
@@ -750,7 +750,7 @@ func newGossipInstance(serviceConfig *ServiceConfig, port int, id int, gRPCServe
750750
)
751751
go gRPCServer.Start()
752752

753-
gossipService := &GossipServiceImpl{
753+
gossipService := &GossipService{
754754
mcs: cryptoService,
755755
gossipSvc: gossip,
756756
chains: make(map[string]state.GossipStateProvider),
@@ -763,16 +763,16 @@ func newGossipInstance(serviceConfig *ServiceConfig, port int, id int, gRPCServe
763763
serviceConfig: serviceConfig,
764764
}
765765

766-
return &gossipGRPC{GossipServiceImpl: gossipService, grpc: gRPCServer}
766+
return &gossipGRPC{GossipService: gossipService, grpc: gRPCServer}
767767
}
768768

769769
type gossipGRPC struct {
770-
*GossipServiceImpl
770+
*GossipService
771771
grpc *comm.GRPCServer
772772
}
773773

774774
func (g *gossipGRPC) Stop() {
775-
g.GossipServiceImpl.Stop()
775+
g.GossipService.Stop()
776776
g.grpc.Stop()
777777
}
778778

gossip/service/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ func TestLeaderYield(t *testing.T) {
137137
socket.Close()
138138

139139
// Helper function that creates a gossipService instance
140-
newGossipService := func(i int) *GossipServiceImpl {
141-
gs := gossips[i].GossipServiceImpl
140+
newGossipService := func(i int) *GossipService {
141+
gs := gossips[i].GossipService
142142
gs.deliveryFactory = &embeddingDeliveryServiceFactory{&deliveryFactoryImpl{}}
143143
gs.InitializeChannel(channelName, []string{endpoint}, Support{
144144
Committer: &mockLedgerInfo{1},

gossip/service/join_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func TestJoinChannelConfig(t *testing.T) {
163163
g1SvcMock.On("JoinChan", mock.Anything, mock.Anything).Run(func(_ mock.Arguments) {
164164
failChan <- struct{}{}
165165
})
166-
g1 := &GossipServiceImpl{secAdv: &secAdvMock{}, peerIdentity: api.PeerIdentityType("OrgMSP0"), gossipSvc: g1SvcMock}
166+
g1 := &GossipService{secAdv: &secAdvMock{}, peerIdentity: api.PeerIdentityType("OrgMSP0"), gossipSvc: g1SvcMock}
167167
g1.updateAnchors(&configMock{
168168
orgs2AppOrgs: map[string]channelconfig.ApplicationOrg{
169169
"Org0": &appOrgMock{id: "Org0"},
@@ -180,7 +180,7 @@ func TestJoinChannelConfig(t *testing.T) {
180180
g2SvcMock.On("JoinChan", mock.Anything, mock.Anything).Run(func(_ mock.Arguments) {
181181
succChan <- struct{}{}
182182
})
183-
g2 := &GossipServiceImpl{secAdv: &secAdvMock{}, peerIdentity: api.PeerIdentityType("Org0"), gossipSvc: g2SvcMock}
183+
g2 := &GossipService{secAdv: &secAdvMock{}, peerIdentity: api.PeerIdentityType("Org0"), gossipSvc: g2SvcMock}
184184
g2.updateAnchors(&configMock{
185185
orgs2AppOrgs: map[string]channelconfig.ApplicationOrg{
186186
"Org0": &appOrgMock{id: "Org0"},
@@ -212,7 +212,7 @@ func TestJoinChannelNoAnchorPeers(t *testing.T) {
212212
assert.Equal(t, "A", string(channel))
213213
})
214214

215-
g := &GossipServiceImpl{secAdv: &secAdvMock{}, peerIdentity: api.PeerIdentityType("Org0"), gossipSvc: gMock}
215+
g := &GossipService{secAdv: &secAdvMock{}, peerIdentity: api.PeerIdentityType("Org0"), gossipSvc: gMock}
216216

217217
appOrg0 := &appOrgMock{id: "Org0"}
218218
appOrg1 := &appOrgMock{id: "Org1"}

internal/peer/node/start.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ func registerDiscoveryService(
725725
peerServer *comm.GRPCServer,
726726
polMgr policies.ChannelPolicyManagerGetter,
727727
metadataProvider *lifecycle.MetadataProvider,
728-
gossipService gossipservice.GossipService,
728+
gossipService *gossipservice.GossipService,
729729
) {
730730
mspID := coreConfig.LocalMSPID
731731
localAccessPolicy := localPolicy(cauthdsl.SignedByAnyAdmin([]string{mspID}))
@@ -949,7 +949,7 @@ func initGossipService(
949949
peerServer *comm.GRPCServer,
950950
signer msp.SigningIdentity,
951951
peerAddr string,
952-
) (gossipservice.GossipService, error) {
952+
) (*gossipservice.GossipService, error) {
953953

954954
var certs *gossipcommon.TLSCertificates
955955
if peerServer.TLSEnabled() {

0 commit comments

Comments
 (0)