1
0

blockchain: blockchains_lock needed to write/iterate global dict

This commit is contained in:
SomberNight
2018-09-16 18:26:40 +02:00
parent 7dc5665ab1
commit 4360a785ad
3 changed files with 21 additions and 14 deletions

View File

@@ -510,8 +510,9 @@ class Interface(PrintError):
chain = self.blockchain.check_header(bad_header)
if not chain:
b = forkfun(bad_header)
assert bad not in blockchain.blockchains, (bad, list(blockchain.blockchains.keys()))
blockchain.blockchains[bad] = b
with blockchain.blockchains_lock:
assert bad not in blockchain.blockchains, (bad, list(blockchain.blockchains))
blockchain.blockchains[bad] = b
self.blockchain = b
height = b.forkpoint + 1
assert b.forkpoint == bad
@@ -540,7 +541,8 @@ class Interface(PrintError):
return True
bad, bad_header = height, header
local_max = max([0] + [x.height() for x in blockchain.blockchains.values()]) if 'mock' not in header else float('inf')
with blockchain.blockchains_lock: chains = list(blockchain.blockchains.values())
local_max = max([0] + [x.height() for x in chains]) if 'mock' not in header else float('inf')
height = min(local_max + 1, height - 1)
while await iterate():
bad, bad_header = height, header