Skip to content

Commit

Permalink
go/consensus/api: Add Registry/Staking/Scheduler to ClientBackend
Browse files Browse the repository at this point in the history
This makes it more convenient to use the consensus client backend.
  • Loading branch information
kostko committed Dec 2, 2020
1 parent 4c6970b commit 0c259c7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/3511.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go/consensus/api: Add Registry/Staking/Scheduler to ClientBackend

This makes it more convenient to use the consensus client backend.
18 changes: 9 additions & 9 deletions go/consensus/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ type ClientBackend interface {

// GetStatus returns the current status overview.
GetStatus(ctx context.Context) (*Status, error)

// Registry returns the registry backend.
Registry() registry.Backend

// Staking returns the staking backend.
Staking() staking.Backend

// Scheduler returns the scheduler backend.
Scheduler() scheduler.Backend
}

// Block is a consensus block.
Expand Down Expand Up @@ -233,17 +242,8 @@ type ServicesBackend interface {
// KeyManager returns the keymanager backend.
KeyManager() keymanager.Backend

// Registry returns the registry backend.
Registry() registry.Backend

// RootHash returns the roothash backend.
RootHash() roothash.Backend

// Staking returns the staking backend.
Staking() staking.Backend

// Scheduler returns the scheduler backend.
Scheduler() scheduler.Backend
}

// TransactionAuthHandler is the interface for handling transaction authentication
Expand Down
15 changes: 15 additions & 0 deletions go/consensus/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
epochtime "github.com/oasisprotocol/oasis-core/go/epochtime/api"
genesis "github.com/oasisprotocol/oasis-core/go/genesis/api"
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
scheduler "github.com/oasisprotocol/oasis-core/go/scheduler/api"
staking "github.com/oasisprotocol/oasis-core/go/staking/api"
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/syncer"
)

Expand Down Expand Up @@ -823,6 +826,18 @@ func (c *consensusClient) WatchBlocks(ctx context.Context) (<-chan *Block, pubsu
return ch, sub, nil
}

func (c *consensusClient) Registry() registry.Backend {
return registry.NewRegistryClient(c.conn)
}

func (c *consensusClient) Staking() staking.Backend {
return staking.NewStakingClient(c.conn)
}

func (c *consensusClient) Scheduler() scheduler.Backend {
return scheduler.NewSchedulerClient(c.conn)
}

// NewConsensusClient creates a new gRPC consensus client service.
func NewConsensusClient(c *grpc.ClientConn) ClientBackend {
return &consensusClient{
Expand Down

0 comments on commit 0c259c7

Please sign in to comment.