added call to new validateMetadata function
This commit is contained in:
parent
f148724e69
commit
956f720741
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user