Fix the "no fleet state available" message

Take this node's fleet state from `known_nodes` instead of the variables set in `update_snapshot`
pull/2378/head
Bogdan Opanchuk 2020-10-16 16:16:06 -07:00
parent fa1caddc0a
commit 26201e716d
3 changed files with 11 additions and 5 deletions

View File

@ -77,6 +77,9 @@ class FleetSensor:
def __repr__(self):
return self._nodes.__repr__()
def population(self):
return len(self) + len(self.additional_nodes_to_track)
@property
def checksum(self):
return self._checksum

View File

@ -855,7 +855,7 @@ class Learner:
current_teacher.update_snapshot(checksum=checksum,
updated=maya.MayaDT(
int.from_bytes(fleet_state_updated_bytes, byteorder="big")),
number_of_known_nodes=len(self.known_nodes))
number_of_known_nodes=self.known_nodes.population())
return FLEET_STATES_MATCH
# Note: There was previously a version check here, but that required iterating through node bytestrings twice,

View File

@ -45,7 +45,12 @@ NO FLEET STATE AVAILABLE
<%def name="fleet_state_icon_from_state(state)">
${fleet_state_icon(state.checksum, state.nickname, len(state))}
${fleet_state_icon(state.checksum, state.nickname, len(state.nodes))}
</%def>
<%def name="fleet_state_icon_from_known_nodes(state)">
${fleet_state_icon(state.checksum, state.nickname, state.population())}
</%def>
@ -170,9 +175,7 @@ ${fleet_state_icon(state.checksum, state.nickname, len(state))}
</tr>
<tr>
<td><i>Fleet state:</i></td>
<td> ${fleet_state_icon(this_node.fleet_state_checksum,
this_node.fleet_state_nickname,
this_node.fleet_state_population)}</td>
<td>${fleet_state_icon_from_known_nodes(this_node.known_nodes)}</td>
</tr>
<tr>
<td><i>Previous states:</i></td>