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

View File

@ -310,6 +310,11 @@ class OnionrUtils:
return retVal 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): def validatePubKey(self, key):
''' '''
Validate if a string is a valid base32 encoded Ed25519 key Validate if a string is a valid base32 encoded Ed25519 key