Correct handling of old knownnodes.dat format at import.
This commit is contained in:
parent
71f3a480da
commit
401c95cdb6
|
@ -49,10 +49,15 @@ def readDefaultKnownNodes(appdata):
|
|||
pickleFile = open(appdata + 'knownnodes.dat', 'rb')
|
||||
knownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
knownNodes
|
||||
for stream, storedValue in knownNodes.items():
|
||||
for host,value in storedValue.items():
|
||||
port, storedtime = storedValue[host]
|
||||
try:
|
||||
# Old knownNodes format.
|
||||
port, storedtime = value
|
||||
except:
|
||||
# New knownNodes format.
|
||||
host, port = host
|
||||
storedtime = value
|
||||
print host, '\t', port, '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(storedtime)),'utf-8')
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -9,8 +9,20 @@ def knownNodes():
|
|||
# We shouldn't have to use the shared.knownNodesLock because this had
|
||||
# better be the only thread accessing knownNodes right now.
|
||||
pickleFile = open(shared.appdata + 'knownnodes.dat', 'rb')
|
||||
shared.knownNodes = pickle.load(pickleFile)
|
||||
loadedKnownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
# The old format of storing knownNodes was as a 'host: (port, time)'
|
||||
# mapping. The new format is as 'Peer: time' pairs. If we loaded
|
||||
# data in the old format, transform it to the new style.
|
||||
for stream, nodes in loadedKnownNodes.items():
|
||||
shared.knownNodes[stream] = {}
|
||||
for node_tuple in nodes.items():
|
||||
try:
|
||||
host, (port, time) = node_tuple
|
||||
peer = shared.Peer(host, port)
|
||||
except:
|
||||
peer, time = node_tuple
|
||||
shared.knownNodes[stream][peer] = time
|
||||
except:
|
||||
shared.knownNodes = defaultKnownNodes.createDefaultKnownNodes(shared.appdata)
|
||||
if shared.config.getint('bitmessagesettings', 'settingsversion') > 6:
|
||||
|
|
Loading…
Reference in New Issue
Block a user