work on pow for public keys

This commit is contained in:
Kevin Froman 2018-05-07 01:55:03 -05:00
parent 54a3557fd0
commit bc88e8107c
No known key found for this signature in database
GPG key ID: 0D414D0FE405B63B
7 changed files with 72 additions and 29 deletions

View file

@ -101,9 +101,16 @@ class OnionrUtils:
retVal = False
if newKeyList != False:
for key in newKeyList.split(','):
if not key in self._core.listPeers(randomOrder=False) and type(key) != None and key != self._core._crypto.pubKey:
if self._core.addPeer(key):
retVal = True
key = key.split('-')
if len(key[0]) > 60 or len(key[1]) > 1000:
logger.warn(key[0] + ' or its pow value is too large.')
continue
if self._core._crypto.blake2bHash(base64.b64decode(key[1]) + key[0]).startswith('0000'):
if not key[0] in self._core.listPeers(randomOrder=False) and type(key) != None and key[0] != self._core._crypto.pubKey:
if self._core.addPeer(key[0], key[1]):
retVal = True
else:
logger.warn(key[0] + 'pow failed')
return retVal
except Exception as error:
logger.error('Failed to merge keys.', error=error)