-
Notifications
You must be signed in to change notification settings - Fork 658
/
health.go
32 lines (26 loc) · 937 Bytes
/
health.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package platformvm
import (
"fmt"
"github.com/ava-labs/avalanchego/utils/constants"
)
// HealthCheck implements the common.VM interface
func (vm *VM) HealthCheck() (interface{}, error) {
// Returns nil if this node is connected to > alpha percent of the Primary Network's stake
percentConnected, err := vm.getPercentConnected()
if err != nil {
return nil, fmt.Errorf("couldn't get percent connected: %w", err)
}
vm.metrics.percentConnected.Set(percentConnected)
details := map[string]float64{
"percentConnected": percentConnected,
}
if percentConnected < constants.MinConnectedStake { // Use alpha from consensus instead of const
return details, fmt.Errorf("connected to %f percent of the stake; should be connected to at least %f",
percentConnected,
constants.MinConnectedStake,
)
}
return details, nil
}