Fix type bug
parent
80648cc920
commit
bd3a3bfeed
|
@ -390,7 +390,7 @@ class Core:
|
||||||
events.event('queue_pop', data = {'data': retData}, onionr = None)
|
events.event('queue_pop', data = {'data': retData}, onionr = None)
|
||||||
|
|
||||||
return retData
|
return retData
|
||||||
|
|
||||||
def makeDaemonDB(self):
|
def makeDaemonDB(self):
|
||||||
'''generate the daemon queue db'''
|
'''generate the daemon queue db'''
|
||||||
conn = sqlite3.connect(self.queueDB)
|
conn = sqlite3.connect(self.queueDB)
|
||||||
|
@ -669,16 +669,18 @@ class Core:
|
||||||
conn.close()
|
conn.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def insertBlock(self, data, header='txt', sign=False, encryptType='', symKey='', asymPeer='', meta = {}):
|
def insertBlock(self, data, header='txt', sign=False, encryptType='', symKey='', asymPeer='', meta = None):
|
||||||
'''
|
'''
|
||||||
Inserts a block into the network
|
Inserts a block into the network
|
||||||
encryptType must be specified to encrypt a block
|
encryptType must be specified to encrypt a block
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
if meta is None:
|
||||||
data.decode()
|
meta = dict()
|
||||||
except AttributeError:
|
|
||||||
data = data.encode()
|
if type(data) is bytes:
|
||||||
|
data = data.decode()
|
||||||
|
data = str(data)
|
||||||
|
|
||||||
retData = ''
|
retData = ''
|
||||||
signature = ''
|
signature = ''
|
||||||
|
@ -686,10 +688,9 @@ class Core:
|
||||||
metadata = {}
|
metadata = {}
|
||||||
|
|
||||||
# only use header if not set in provided meta
|
# only use header if not set in provided meta
|
||||||
try:
|
if not header is None:
|
||||||
meta['type']
|
meta['type'] = header
|
||||||
except KeyError:
|
meta['type'] = str(meta['type'])
|
||||||
meta['type'] = header # block type
|
|
||||||
|
|
||||||
jsonMeta = json.dumps(meta)
|
jsonMeta = json.dumps(meta)
|
||||||
|
|
||||||
|
@ -709,7 +710,7 @@ class Core:
|
||||||
|
|
||||||
if len(jsonMeta) > 1000:
|
if len(jsonMeta) > 1000:
|
||||||
raise onionrexceptions.InvalidMetadata('meta in json encoded form must not exceed 1000 bytes')
|
raise onionrexceptions.InvalidMetadata('meta in json encoded form must not exceed 1000 bytes')
|
||||||
|
|
||||||
# encrypt block metadata/sig/content
|
# encrypt block metadata/sig/content
|
||||||
if encryptType == 'sym':
|
if encryptType == 'sym':
|
||||||
if len(symKey) < self.requirements.passwordLength:
|
if len(symKey) < self.requirements.passwordLength:
|
||||||
|
@ -736,7 +737,7 @@ class Core:
|
||||||
powToken = powToken.decode()
|
powToken = powToken.decode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# compile metadata
|
# compile metadata
|
||||||
metadata['meta'] = jsonMeta
|
metadata['meta'] = jsonMeta
|
||||||
metadata['sig'] = signature
|
metadata['sig'] = signature
|
||||||
|
|
|
@ -496,7 +496,6 @@ class Block:
|
||||||
- child (str/Block): the child Block to be followed
|
- child (str/Block): the child Block to be followed
|
||||||
- file (str/file): the file to write the content to, instead of returning it
|
- file (str/file): the file to write the content to, instead of returning it
|
||||||
- maximumFollows (int): the maximum number of Blocks to follow
|
- maximumFollows (int): the maximum number of Blocks to follow
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# validate data and instantiate Core
|
# validate data and instantiate Core
|
||||||
|
|
Loading…
Reference in New Issue