Skip to content

Commit

Permalink
Improvements on Status service (#821)
Browse files Browse the repository at this point in the history
* improve status service usage
* simplify reshare status on status service
  • Loading branch information
emmanuelm41 committed Sep 30, 2021
1 parent 0cf33c1 commit 6590940
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 126 deletions.
22 changes: 0 additions & 22 deletions core/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,3 @@ var DefaultResharingOffset = 30 * time.Second

// PrivateRandLength is the length of expected private randomness buffers
const PrivateRandLength = 32

type DkgStatus uint32

const (
DkgReady DkgStatus = iota
DkgInProgress
DkgNotStarted
)

type ReshareStatus uint32

const (
ReshareNotInProgress ReshareStatus = iota
ReshareInProgress
)

type BeaconStatus uint32

const (
BeaconNotInited BeaconStatus = iota
BeaconInited
)
9 changes: 4 additions & 5 deletions core/drand_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,14 @@ func (d *Drand) Status(c context.Context, in *drand.StatusRequest) (*drand.Statu
}

// Reshare status
switch {
case !d.dkgDone:
reshareStatus.Status = uint32(ReshareNotInProgress)
if d.dkgDone && d.receiver != nil {
reshareStatus.Status = uint32(ReshareInProgress)
case d.dkgDone && d.receiver != nil:
reshareStatus.Status = uint32(ReshareNotInProgress)
}

// Beacon status
beaconStatus.Status = uint32(BeaconNotInited)
chainStore.IsEmpty = true

if d.beacon != nil {
beaconStatus.Status = uint32(BeaconInited)
Expand All @@ -608,7 +607,7 @@ func (d *Drand) Status(c context.Context, in *drand.StatusRequest) (*drand.Statu
lastBeacon, err := d.beacon.Store().Last()

if err == nil && lastBeacon != nil {
chainStore.IsAnyRound = true
chainStore.IsEmpty = false
chainStore.LastRound = lastBeacon.GetRound()
chainStore.Length = uint64(d.beacon.Store().Len())
}
Expand Down
27 changes: 27 additions & 0 deletions core/drand_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package core

const UnknownDesc = "Unknown"
const NotStartedDesc = "Not started"
const InProgressDesc = "In progress"

type DkgStatus uint32

const (
DkgReady DkgStatus = iota
DkgInProgress
DkgNotStarted
)

type ReshareStatus uint32

const (
ReshareNotInProgress ReshareStatus = iota
ReshareInProgress
)

type BeaconStatus uint32

const (
BeaconNotInited BeaconStatus = iota
BeaconInited
)
2 changes: 1 addition & 1 deletion core/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func (d *DrandTestScenario) WaitUntilRound(t *testing.T, node *MockNode, round u
status, err := newClient.Status()
require.NoError(t, err)

if status.ChainStore.IsAnyRound && status.ChainStore.LastRound == round {
if !status.ChainStore.IsEmpty && status.ChainStore.LastRound == round {
t.Logf("node %s is on expected round (%d)", node.addr, status.ChainStore.LastRound)
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions net/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func (c *ControlClient) Ping() error {

// Status gets the current daemon status
func (c *ControlClient) Status() (*control.StatusResponse, error) {
pong, err := c.client.Status(ctx.Background(), &control.StatusRequest{})
return pong, err
resp, err := c.client.Status(ctx.Background(), &control.StatusRequest{})
return resp, err
}

// InitReshareLeader sets up the node to be ready for a resharing protocol.
Expand Down
190 changes: 95 additions & 95 deletions protobuf/drand/control.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion protobuf/drand/control.proto
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ message BeaconStatus{
}

message ChainStoreStatus{
bool is_any_round = 1;
bool is_empty = 1;
uint64 last_round = 2;
uint64 length = 3;
}
Expand Down

0 comments on commit 6590940

Please sign in to comment.