lbry-sdk/lbrynet/lbrynet_daemon/daemon_scripts/migrateto025.py
Jack a9f99d05b9 add more known dht nodes
also fix migrator bug
2016-06-03 20:20:16 -04:00

32 lines
1 KiB
Python

from twisted.internet import defer
class migrator(object):
"""
Re-resolve lbry names to write missing data to blockchain.db and to cache the nametrie
"""
def __init__(self, api):
self._api = api
def start(self):
def _resolve_claims(claimtrie):
claims = [i for i in claimtrie if 'txid' in i.keys()]
r = defer.DeferredList([self._api._resolve_name(claim['name'], force_refresh=True) for claim in claims], consumeErrors=True)
return r
def _restart_lbry_files():
def _restart_lbry_file(lbry_file):
return lbry_file.restore()
r = defer.DeferredList([_restart_lbry_file(lbry_file) for lbry_file in self._api.lbry_file_manager.lbry_files if not lbry_file.txid], consumeErrors=True)
return r
d = self._api.session.wallet.get_nametrie()
d.addCallback(_resolve_claims)
d.addCallback(lambda _: _restart_lbry_files())
def run(api):
refresher = migrator(api)
refresher.start()