|
|
@ -131,6 +131,21 @@ func (m *Monitor) NodeByName(name string) (index int, node *Node) { |
|
|
|
return -1, nil |
|
|
|
} |
|
|
|
|
|
|
|
// NodeIsOnline is called when connection to the node is restored.
|
|
|
|
// Must be safe to call multiple times.
|
|
|
|
func (m *Monitor) NodeIsOnline(name string) { |
|
|
|
|
|
|
|
_, node := m.NodeByName(name) |
|
|
|
if nil != node { |
|
|
|
if online, ok := m.Network.nodeStatusMap[name]; ok && online { |
|
|
|
m.mtx.Lock() |
|
|
|
node.Online = online |
|
|
|
m.mtx.Unlock() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Start starts the monitor's routines: recalculating network uptime and
|
|
|
|
// updating number of validators.
|
|
|
|
func (m *Monitor) Start() error { |
|
|
@ -160,14 +175,17 @@ func (m *Monitor) listen(nodeName string, blockCh <-chan tmtypes.Header, blockLa |
|
|
|
case b := <-blockCh: |
|
|
|
m.Network.NewBlock(b) |
|
|
|
m.Network.NodeIsOnline(nodeName) |
|
|
|
m.NodeIsOnline(nodeName) |
|
|
|
case l := <-blockLatencyCh: |
|
|
|
m.Network.NewBlockLatency(l) |
|
|
|
m.Network.NodeIsOnline(nodeName) |
|
|
|
m.NodeIsOnline(nodeName) |
|
|
|
case disconnected := <-disconnectCh: |
|
|
|
if disconnected { |
|
|
|
m.Network.NodeIsDown(nodeName) |
|
|
|
} else { |
|
|
|
m.Network.NodeIsOnline(nodeName) |
|
|
|
m.NodeIsOnline(nodeName) |
|
|
|
} |
|
|
|
case <-time.After(nodeLivenessTimeout): |
|
|
|
logger.Info("event", fmt.Sprintf("node was not responding for %v", nodeLivenessTimeout)) |
|
|
|