added call to new validateMetadata function

master
Kevin Froman 2018-06-25 02:34:43 -05:00
parent f148724e69
commit 956f720741
2 changed files with 7 additions and 3 deletions

View File

@ -64,7 +64,6 @@ class OnionrCommunicatorDaemon:
OnionrCommunicatorTimers(self, self.lookupBlocks, 7)
OnionrCommunicatorTimers(self, self.getBlocks, 10)
OnionrCommunicatorTimers(self, self.clearOfflinePeer, 120)
OnionrCommunicatorTimers(self, self.lookupKeys, 125)
OnionrCommunicatorTimers(self, self.lookupAdders, 600)
@ -138,13 +137,13 @@ class OnionrCommunicatorDaemon:
metas = self._core._utils.getBlockMetadataFromData(content)
metadata = metas[0]
meta = metas[1]
if self._core._crypto.verifyPow(metas[2], metadata):
if self._core._crypto.verifyPow(metas[2], metadata) and self._core._utils.validateMetadata(metadata):
logger.info('Block passed proof, saving.')
self._core.setData(content)
self._core.addToBlockDB(blockHash, dataSaved=True)
self.blockQueue.remove(blockHash)
else:
logger.warn('POW failed for block ' + blockHash)
self.blockQueue.remove(blockHash)
else:
logger.warn('Block hash validation failed for ' + blockHash + ' got ' + self._core._crypto.sha3Hash(content))
self.decrementThreadCount('getBlocks')

View File

@ -310,6 +310,11 @@ class OnionrUtils:
return retVal
def validateMetadata(metadata):
'''Validate metadata meets onionr spec (does not validate proof value computation), take in either dictionary or json string'''
# TODO, make this check sane sizes
return True
def validatePubKey(self, key):
'''
Validate if a string is a valid base32 encoded Ed25519 key