def make_block(prev_block, txs, pubkey, DB): leng=int(prev_block['length'])+1 target=blockchain.target(DB, leng) diffLength=blockchain.hexSum(prev_block['diffLength'], blockchain.hexInvert(target)) out={'version':custom.version, 'txs':txs+[make_mint(pubkey, DB)], 'length':leng, 'time':time.time(), 'diffLength':diffLength, 'target':target, 'prevHash':tools.det_hash(prev_block)} out=tools.unpackage(tools.package(out)) return out
def make_block(prev_block, txs, pubkey, DB): leng = int(prev_block['length']) + 1 target = blockchain.target(DB, leng) diffLength = blockchain.hexSum(prev_block['diffLength'], blockchain.hexInvert(target)) out = {'version': custom.version, 'txs': txs + [make_mint(pubkey, DB)], 'length': leng, 'time': time.time(), 'diffLength': diffLength, 'target': target, 'prevHash': tools.det_hash(prev_block)} out = tools.unpackage(tools.package(out)) return out
def sumTargets(l): if len(l) < 1: return 0 while len(l) > 1: l = [blockchain.hexSum(l[0], l[1])] + l[2:] return l[0]