Add newline delimiter to metadata+content

This commit is contained in:
Arinerron 2018-05-12 20:55:34 -07:00
parent fe4261c4a2
commit f9b93fd491
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
3 changed files with 8 additions and 8 deletions

View File

@ -517,7 +517,7 @@ class OnionrCommunicate:
'''
if isThread:
self.processBlocksThreads += 1
for i in self._core.getBlockList(unsaved=True).split("\n"):
for i in self._core.getBlockList(unsaved = True):
if i != "":
if i in self.blocksProcessing or i in self.ignoredHashes:
#logger.debug('already processing ' + i)
@ -553,13 +553,13 @@ class OnionrCommunicate:
pass
try:
#blockMetadata = json.loads(self._core.getData(i)).split('}')[0] + '}'
blockMetadata = json.loads(blockContent[:blockContent.rfind(b'}') + 1].decode())
blockMetadata = json.loads(blockContent[:blockContent.find(b'\n')].decode())
try:
blockMeta2 = json.loads(blockMetadata['meta'])
except KeyError:
blockMeta2 = {'type': ''}
pass
blockContent = blockContent[blockContent.rfind(b'}') + 1:]
blockContent = blockContent[blockContent.find(b'\n') + 1:]
try:
blockContent = blockContent.decode()
except AttributeError:

View File

@ -678,7 +678,7 @@ class Core:
signature = ''
if sign:
signature = self._crypto.edSign(metadata + data, self._crypto.privKey, encodeResult=True)
signature = self._crypto.edSign(metadata + b'\n' + data, self._crypto.privKey, encodeResult=True)
ourID = self._crypto.pubKeyHashID()
# Convert from bytes on some py versions?
try:
@ -692,7 +692,7 @@ class Core:
if len(data) == 0:
logger.error('Will not insert empty block')
else:
addedHash = self.setData(metadata + data)
addedHash = self.setData(metadata + b'\n' + data)
self.addToBlockDB(addedHash, selfInsert=True)
self.setBlockType(addedHash, header)
retData = addedHash

View File

@ -334,7 +334,7 @@ class OnionrUtils:
'''
Find, decrypt, and return array of PMs (array of dictionary, {from, text})
'''
#blocks = self._core.getBlockList().split('\n')
#blocks = self._core.getBlockList()
blocks = self._core.getBlocksByType('pm')
message = ''
sender = ''
@ -344,8 +344,8 @@ class OnionrUtils:
try:
with open('data/blocks/' + i + '.dat', 'r') as potentialMessage:
potentialMessage = potentialMessage.read()
blockMetadata = json.loads(potentialMessage[:potentialMessage.rfind('}') + 1])
blockContent = potentialMessage[potentialMessage.rfind('}') + 1:]
blockMetadata = json.loads(potentialMessage[:potentialMessage.find('\n')])
blockContent = potentialMessage[potentialMessage.find('\n') + 1:]
try:
message = self._core._crypto.pubKeyDecrypt(blockContent, encodedData=True, anonymous=True)