Beispiel #1
0
def lightweight():
    fullchain = [json.loads(block) for block in blockchain.chain]
    lightWeight = []
    for block in fullchain:
        blockObject = Block(block['index'], block['transactions'],
                            block['timestamp'], block['previous_hash'],
                            block['difficulty'])
        blockObject.merkle_root = block['merkle_root']
        blockObject.nonce = block['nonce']
        blockObject.difficulty = block['difficulty']
        lightWeight.append(blockObject.to_dict())
    response = {'chain': json.dumps(lightWeight), 'length': len(lightWeight)}
    return jsonify(response), 200