Correctly propogate websocket changes and modify RPC check to invalidate nodes by most common blockheight value

tempfix
dsc 3 years ago
parent 28fdf41aad
commit d127825a70

@ -97,9 +97,7 @@ class FeatherTask:
for queue in connected_websockets: for queue in connected_websockets:
await queue.put({ await queue.put({
"cmd": self._websocket_cmd, "cmd": self._websocket_cmd,
"data": { "data": result
self._websocket_cmd: result
}
}) })
# optional: cache the result # optional: cache the result

@ -58,23 +58,19 @@ class RPCNodeCheckTask(FeatherTask):
continue continue
# Filter out nodes affected by < v0.17.1.3 sybil attack # Filter out nodes affected by < v0.17.1.3 sybil attack
data = list(map(lambda node: node if node['target_height'] <= node['height'] data = list(map(lambda _node: _node if _node['target_height'] <= _node['height']
else self._bad_node(**node), data)) else self._bad_node(**_node), data))
allowed_offset = 3 allowed_offset = 3
valid_heights = [] valid_heights = []
current_blockheight = heights.get(network_type_coin, 0) # current_blockheight = heights.get(network_type_coin, 0)
if isinstance(current_blockheight, int) and current_blockheight > 0: # popularity contest
# blockheight from cache has precedence common_height = popularity_contest([z['height'] for z in data])
valid_heights = range(current_blockheight, current_blockheight - allowed_offset, -1) valid_heights = range(common_height, common_height - allowed_offset, -1)
else:
# popularity contest data = list(map(lambda _node: _node if _node['height'] in valid_heights
common_height = popularity_contest([z['height'] for z in data]) else self._bad_node(**_node), data))
valid_heights = range(common_height, common_height - allowed_offset, -1)
data = list(map(lambda node: node if node['height'] in valid_heights
else self._bad_node(**node), data))
nodes += data nodes += data
return nodes return nodes

Loading…
Cancel
Save