Fix type bug

This commit is contained in:
Arinerron 2018-07-04 12:07:17 -07:00
parent 80648cc920
commit bd3a3bfeed
2 changed files with 13 additions and 13 deletions

View File

@ -669,16 +669,18 @@ class Core:
conn.close()
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
encryptType must be specified to encrypt a block
'''
try:
data.decode()
except AttributeError:
data = data.encode()
if meta is None:
meta = dict()
if type(data) is bytes:
data = data.decode()
data = str(data)
retData = ''
signature = ''
@ -686,10 +688,9 @@ class Core:
metadata = {}
# only use header if not set in provided meta
try:
meta['type']
except KeyError:
meta['type'] = header # block type
if not header is None:
meta['type'] = header
meta['type'] = str(meta['type'])
jsonMeta = json.dumps(meta)

View File

@ -496,7 +496,6 @@ class Block:
- child (str/Block): the child Block to be followed
- file (str/file): the file to write the content to, instead of returning it
- maximumFollows (int): the maximum number of Blocks to follow
'''
# validate data and instantiate Core