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.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')
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user