Skip to content

Commit 9621e09

Browse files
committed
go/consensus/cometbft/api: Remove service descriptor interface
1 parent 5911b1d commit 9621e09

9 files changed

Lines changed: 28 additions & 36 deletions

File tree

go/consensus/cometbft/api/api.go

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -307,46 +307,23 @@ type ServiceEvent struct {
307307
}
308308

309309
// ServiceDescriptor is a CometBFT consensus service descriptor.
310-
type ServiceDescriptor interface {
311-
// Name returns the name of this service.
312-
Name() string
313-
314-
// EventType returns the event type associated with the consensus service.
315-
EventType() string
316-
317-
// Queries returns a channel that emits queries that need to be subscribed to.
318-
Queries() <-chan cmtpubsub.Query
319-
}
320-
321-
type serviceDescriptor struct {
310+
type ServiceDescriptor struct {
322311
name string
323312
eventType string
324313
queryCh <-chan cmtpubsub.Query
325314
}
326315

327-
func (sd *serviceDescriptor) Name() string {
328-
return sd.name
329-
}
330-
331-
func (sd *serviceDescriptor) EventType() string {
332-
return sd.eventType
333-
}
334-
335-
func (sd *serviceDescriptor) Queries() <-chan cmtpubsub.Query {
336-
return sd.queryCh
337-
}
338-
339316
// NewServiceDescriptor creates a new consensus service descriptor.
340-
func NewServiceDescriptor(name, eventType string, queryCh <-chan cmtpubsub.Query) ServiceDescriptor {
341-
return &serviceDescriptor{
317+
func NewServiceDescriptor(name, eventType string, queryCh <-chan cmtpubsub.Query) *ServiceDescriptor {
318+
return &ServiceDescriptor{
342319
name: name,
343320
eventType: eventType,
344321
queryCh: queryCh,
345322
}
346323
}
347324

348325
// NewStaticServiceDescriptor creates a new static consensus service descriptor.
349-
func NewStaticServiceDescriptor(name, eventType string, queries []cmtpubsub.Query) ServiceDescriptor {
326+
func NewStaticServiceDescriptor(name, eventType string, queries []cmtpubsub.Query) *ServiceDescriptor {
350327
ch := make(chan cmtpubsub.Query)
351328
go func() {
352329
for _, q := range queries {
@@ -356,10 +333,25 @@ func NewStaticServiceDescriptor(name, eventType string, queries []cmtpubsub.Quer
356333
return NewServiceDescriptor(name, eventType, ch)
357334
}
358335

336+
// Name returns the name of this service.
337+
func (sd *ServiceDescriptor) Name() string {
338+
return sd.name
339+
}
340+
341+
// EventType returns the event type associated with the consensus service.
342+
func (sd *ServiceDescriptor) EventType() string {
343+
return sd.eventType
344+
}
345+
346+
// Queries returns a channel that emits queries that need to be subscribed to.
347+
func (sd *ServiceDescriptor) Queries() <-chan cmtpubsub.Query {
348+
return sd.queryCh
349+
}
350+
359351
// ServiceClient is a consensus service client.
360352
type ServiceClient interface {
361353
// ServiceDescriptor returns the consensus service descriptor.
362-
ServiceDescriptor() ServiceDescriptor
354+
ServiceDescriptor() *ServiceDescriptor
363355

364356
// DeliverHeight delivers a new block height.
365357
DeliverHeight(ctx context.Context, height int64) error

go/consensus/cometbft/beacon/beacon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func (sc *ServiceClient) WatchLatestVRFEvent(context.Context) (<-chan *beaconAPI
243243
return ch, sub, nil
244244
}
245245

246-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
246+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
247247
return tmapi.NewStaticServiceDescriptor("beacon", app.EventType, []cmtpubsub.Query{app.QueryApp})
248248
}
249249

go/consensus/cometbft/governance/governance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (sc *ServiceClient) ConsensusParameters(ctx context.Context, height int64)
163163
}
164164

165165
// ServiceDescriptor implements api.ServiceClient.
166-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
166+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
167167
return tmapi.NewStaticServiceDescriptor(api.ModuleName, app.EventType, []cmtpubsub.Query{app.QueryApp})
168168
}
169169

go/consensus/cometbft/keymanager/keymanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (sc *ServiceClient) Churp() churpAPI.Backend {
6363
}
6464

6565
// ServiceDescriptor implements api.ServiceClient.
66-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
66+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
6767
return tmapi.NewStaticServiceDescriptor(api.ModuleName, app.EventType, []cmtpubsub.Query{app.QueryApp})
6868
}
6969

go/consensus/cometbft/registry/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func (sc *ServiceClient) ConsensusParameters(ctx context.Context, height int64)
238238
}
239239

240240
// ServiceDescriptor implements api.ServiceClient.
241-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
241+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
242242
return tmapi.NewStaticServiceDescriptor(api.ModuleName, app.EventType, []cmtpubsub.Query{app.QueryApp})
243243
}
244244

go/consensus/cometbft/roothash/roothash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func (sc *ServiceClient) getRuntimeNotifiers(id common.Namespace) *runtimeBroker
329329
}
330330

331331
// ServiceDescriptor implements api.ServiceClient.
332-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
332+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
333333
return tmapi.NewServiceDescriptor(api.ModuleName, app.EventType, sc.queryCh)
334334
}
335335

go/consensus/cometbft/scheduler/scheduler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (sc *ServiceClient) getCurrentCommittees() ([]*api.Committee, error) {
115115
}
116116

117117
// ServiceDescriptor implements api.ServiceClient.
118-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
118+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
119119
return tmapi.NewStaticServiceDescriptor(api.ModuleName, app.EventType, []cmtpubsub.Query{app.QueryApp})
120120
}
121121

go/consensus/cometbft/staking/staking.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (sc *ServiceClient) ConsensusParameters(ctx context.Context, height int64)
310310
}
311311

312312
// ServiceDescriptor implements api.ServiceClient.
313-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
313+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
314314
return tmapi.NewStaticServiceDescriptor(api.ModuleName, app.EventType, []cmtpubsub.Query{app.QueryApp})
315315
}
316316

go/consensus/cometbft/vault/vault.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (sc *ServiceClient) ConsensusParameters(ctx context.Context, height int64)
153153
}
154154

155155
// ServiceDescriptor implements api.ServiceClient.
156-
func (sc *ServiceClient) ServiceDescriptor() tmapi.ServiceDescriptor {
156+
func (sc *ServiceClient) ServiceDescriptor() *tmapi.ServiceDescriptor {
157157
return tmapi.NewStaticServiceDescriptor(vault.ModuleName, app.EventType, []cmtpubsub.Query{app.QueryApp})
158158
}
159159

0 commit comments

Comments
 (0)