work on fixing mallable metadata & thread work
parent
ab1cce3616
commit
ff5bdd62f2
|
@ -103,14 +103,14 @@ class OnionrCommunicate:
|
||||||
logger.debug('Communicator heartbeat')
|
logger.debug('Communicator heartbeat')
|
||||||
heartBeatTimer = 0
|
heartBeatTimer = 0
|
||||||
if blockProcessTimer == blockProcessAmount:
|
if blockProcessTimer == blockProcessAmount:
|
||||||
lT1 = threading.Thread(target=self.lookupBlocks, name="lt1", args=(isThread=True,))
|
lT1 = threading.Thread(target=self.lookupBlocks, name="lt1", args=(True,))
|
||||||
lT2 = threading.Thread(target=self.lookupBlocks, name="lt2", args=(isThread=True,))
|
lT2 = threading.Thread(target=self.lookupBlocks, name="lt2", args=(True,))
|
||||||
lT3 = threading.Thread(target=self.lookupBlocks, name="lt3", args=(isThread=True,))
|
lT3 = threading.Thread(target=self.lookupBlocks, name="lt3", args=(True,))
|
||||||
lT4 = threading.Thread(target=self.lookupBlocks, name="lt4", args=(isThread=True,))
|
lT4 = threading.Thread(target=self.lookupBlocks, name="lt4", args=(True,))
|
||||||
pbT1 = threading.Thread(target=self.processBlocks, name='pbT1', args=(isThread=True,))
|
pbT1 = threading.Thread(target=self.processBlocks, name='pbT1', args=(True,))
|
||||||
pbT2 = threading.Thread(target=self.processBlocks, name='pbT2', args=(isThread=True,))
|
pbT2 = threading.Thread(target=self.processBlocks, name='pbT2', args=(True,))
|
||||||
pbT3 = threading.Thread(target=self.processBlocks, name='pbT3', args=(isThread=True,))
|
pbT3 = threading.Thread(target=self.processBlocks, name='pbT3', args=(True,))
|
||||||
pbT4 = threading.Thread(target=self.processBlocks, name='pbT4', args=(isThread=True,))
|
pbT4 = threading.Thread(target=self.processBlocks, name='pbT4', args=(True,))
|
||||||
if (self.maxThreads - 8) >= threading.active_count():
|
if (self.maxThreads - 8) >= threading.active_count():
|
||||||
lT1.start()
|
lT1.start()
|
||||||
lT2.start()
|
lT2.start()
|
||||||
|
@ -550,22 +550,25 @@ class OnionrCommunicate:
|
||||||
blockContent = self._core.getData(i)
|
blockContent = self._core.getData(i)
|
||||||
try:
|
try:
|
||||||
#blockMetadata = json.loads(self._core.getData(i)).split('}')[0] + '}'
|
#blockMetadata = json.loads(self._core.getData(i)).split('}')[0] + '}'
|
||||||
blockMetadata = self._core.getData(i).split(b'}')[0]
|
blockMetadata = self._core.getData(i)
|
||||||
|
blockMetadata = json.loads(blockMetadata[:blockMetadata.rfind(b'}') + 1])
|
||||||
try:
|
try:
|
||||||
blockMetadata = blockMetadata.decode()
|
blockMetadata = blockMetadata.decode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
blockMetadata = json.loads(blockMetadata + '}')
|
#blockMetadata = json.loads(blockMetadata + '}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
blockMetadata['sig']
|
blockMetadata['sig']
|
||||||
blockMetadata['id']
|
blockMetadata['meta']['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
creator = self._utils.getPeerByHashId(blockMetadata['id'])
|
blockData = json.dumps(blockMetadata['meta']) + blockMetadata[blockMetadata.rfind(b'}') + 1:]
|
||||||
|
|
||||||
|
creator = self._utils.getPeerByHashId(blockMetadata['meta']['id'])
|
||||||
try:
|
try:
|
||||||
creator = creator.decode()
|
creator = creator.decode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -637,20 +637,22 @@ class Core:
|
||||||
|
|
||||||
retData = ''
|
retData = ''
|
||||||
metadata = {'type': header}
|
metadata = {'type': header}
|
||||||
|
sig = {}
|
||||||
|
|
||||||
|
metadata = json.dumps(metadata)
|
||||||
|
metadata = metadata.encode()
|
||||||
|
|
||||||
if sign:
|
if sign:
|
||||||
signature = self._crypto.edSign(data, self._crypto.privKey, encodeResult=True)
|
signature = self._crypto.edSign(metadata + data, self._crypto.privKey, encodeResult=True)
|
||||||
ourID = self._crypto.pubKeyHashID()
|
ourID = self._crypto.pubKeyHashID()
|
||||||
# Convert from bytes on some py versions?
|
# Convert from bytes on some py versions?
|
||||||
try:
|
try:
|
||||||
ourID = ourID.decode()
|
ourID = ourID.decode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
metadata['id'] = ourID
|
metadata = {'sig': signature, 'meta': metadata.decode()}
|
||||||
metadata['sig'] = signature
|
metadata = json.dumps(metadata)
|
||||||
|
metadata = metadata.encode()
|
||||||
metadata = json.dumps(metadata)
|
|
||||||
metadata = metadata.encode()
|
|
||||||
|
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
logger.error('Will not insert empty block')
|
logger.error('Will not insert empty block')
|
||||||
|
|
Loading…
Reference in New Issue