Skip to content

Commit

Permalink
Move HealthCheck lock from Handler into Engines (#2173)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Oct 19, 2023
1 parent 26b1505 commit a21d0cf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions snow/engine/avalanche/bootstrap/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ func (b *bootstrapper) Start(ctx context.Context, startReqID uint32) error {
}

func (b *bootstrapper) HealthCheck(ctx context.Context) (interface{}, error) {
b.Ctx.Lock.Lock()
defer b.Ctx.Lock.Unlock()

vmIntf, vmErr := b.VM.HealthCheck(ctx)
intf := map[string]interface{}{
"consensus": struct{}{},
Expand Down
3 changes: 3 additions & 0 deletions snow/engine/snowman/bootstrap/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ func (b *bootstrapper) Notify(_ context.Context, msg common.Message) error {
}

func (b *bootstrapper) HealthCheck(ctx context.Context) (interface{}, error) {
b.Ctx.Lock.Lock()
defer b.Ctx.Lock.Unlock()

vmIntf, vmErr := b.VM.HealthCheck(ctx)
intf := map[string]interface{}{
"consensus": struct{}{},
Expand Down
3 changes: 3 additions & 0 deletions snow/engine/snowman/syncer/state_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ func (*stateSyncer) Timeout(context.Context) error {
}

func (ss *stateSyncer) HealthCheck(ctx context.Context) (interface{}, error) {
ss.Ctx.Lock.Lock()
defer ss.Ctx.Lock.Unlock()

vmIntf, vmErr := ss.VM.HealthCheck(ctx)
intf := map[string]interface{}{
"consensus": struct{}{},
Expand Down
3 changes: 3 additions & 0 deletions snow/engine/snowman/transitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ func (t *Transitive) Start(ctx context.Context, startReqID uint32) error {
}

func (t *Transitive) HealthCheck(ctx context.Context) (interface{}, error) {
t.Ctx.Lock.Lock()
defer t.Ctx.Lock.Unlock()

consensusIntf, consensusErr := t.Consensus.HealthCheck(ctx)
vmIntf, vmErr := t.VM.HealthCheck(ctx)
intf := map[string]interface{}{
Expand Down
3 changes: 0 additions & 3 deletions snow/networking/handler/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import (
var ErrNotConnectedEnoughStake = errors.New("not connected to enough stake")

func (h *handler) HealthCheck(ctx context.Context) (interface{}, error) {
h.ctx.Lock.Lock()
defer h.ctx.Lock.Unlock()

state := h.ctx.State.Get()
engine, ok := h.engineManager.Get(state.Type).Get(state.State)
if !ok {
Expand Down

0 comments on commit a21d0cf

Please sign in to comment.