mirror of
https://git.wownero.com/wowlet/wowlet-backend.git
synced 2024-08-15 01:03:13 +00:00
Correctly propogate websocket changes and modify RPC check to invalidate nodes by most common blockheight value
This commit is contained in:
parent
28fdf41aad
commit
d127825a70
2 changed files with 9 additions and 15 deletions
|
@ -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
|
|
||||||
common_height = popularity_contest([z['height'] for z in data])
|
|
||||||
valid_heights = range(common_height, common_height - allowed_offset, -1)
|
|
||||||
|
|
||||||
data = list(map(lambda node: node if node['height'] in valid_heights
|
data = list(map(lambda _node: _node if _node['height'] in valid_heights
|
||||||
else self._bad_node(**node), data))
|
else self._bad_node(**_node), data))
|
||||||
nodes += data
|
nodes += data
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue