Skip to content

Commit

Permalink
beacon: Add a minimal gRPC service
Browse files Browse the repository at this point in the history
This moves the following calls to the new beacon gRPC service:
 * `Consensus.GetEpoch`
 * `Consensus.WaitEpoch`
 * `Consensus.BeaconConsensusParameters` -> `Beacon.ConsensusParameters`
  • Loading branch information
Yawning committed Feb 10, 2021
1 parent b393f1e commit b7919a4
Show file tree
Hide file tree
Showing 24 changed files with 479 additions and 224 deletions.
4 changes: 4 additions & 0 deletions .changelog/3666.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
beacon: Add a minimal gRPC service

I would put something more descriptive in here, but the change log
fragment CI linter continues to terrorize me.
11 changes: 9 additions & 2 deletions go/beacon/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,26 @@ type Backend interface {
// epoch.
GetEpochBlock(context.Context, EpochTime) (int64, error)

// WaitEpoch waits for a specific epoch.
//
// Note that an epoch is considered reached even if any epoch greater
// than the one specified is reached (e.g., that the current epoch
// is already in the future).
WaitEpoch(ctx context.Context, epoch EpochTime) error

// WatchEpochs returns a channel that produces a stream of messages
// on epoch transitions.
//
// Upon subscription the current epoch is sent immediately.
WatchEpochs() (<-chan EpochTime, *pubsub.Subscription)
WatchEpochs(ctx context.Context) (<-chan EpochTime, pubsub.ClosableSubscription, error)

// WatchLatestEpoch returns a channel that produces a stream of
// messages on epoch transitions. If an epoch transition happens
// before the previous epoch is read from the channel, the old
// epochs are overwritten.
//
// Upon subscription the current epoch is sent immediately.
WatchLatestEpoch() (<-chan EpochTime, *pubsub.Subscription)
WatchLatestEpoch(ctx context.Context) (<-chan EpochTime, pubsub.ClosableSubscription, error)

// GetBeacon gets the beacon for the provided block height.
// Calling this method with height `consensus.HeightLatest` should
Expand Down
Loading

0 comments on commit b7919a4

Please sign in to comment.