Exemplo n.º 1
0
#!flask/bin/python

import json
import time
from BlockChain import Blockchain
import wallet
from Good import Land, Vehicle
from flask import Flask, jsonify, abort, make_response, request

app = Flask(__name__)

blockchain = Blockchain()
users = []
currentUser = 0
walletAlice = wallet.Wallet(
    [Vehicle(1, 1, 53451162589, "red", "wolkswagen")], [
        Land(1, 37, 38, "29 rue parc dounia", [(37.01, 38.002),
                                               (37.2, 36, 2)], 100, 1),
        Land(2, 37, 38, "28 rue parc dounia", [(37.01, 38.002),
                                               (37.2, 36, 2)], 200, 2)
    ])
walletBob = wallet.Wallet([], [
    Land(1, 37, 38, "29 rue parc dounia", [(37.01, 38.002),
                                           (37.2, 36, 2)], 400, 0)
])


@app.route('/login', methods=['POST'])
def login():
    login_data = request.get_json()
    required_fields = ["email", "password"]
Exemplo n.º 2
0
 def test_blockchain(self):
     blockchain = Blockchain()
     blockchain.add_new_transaction("Test Data")
     self.assertEqual(blockchain.mine(), True)
     self.assertEqual(blockchain.chain_valid(blockchain.chain), True)
     self.assertEqual(len(blockchain.chain), 2)
Exemplo n.º 3
0
import hashlib
import datetime
import time
import json

from BlockChain import Blockchain

#ここを0x1d777777に変更する
INITIAL_BITS = 0x1e777777

if __name__ == "__main__":
    bc = Blockchain(INITIAL_BITS)
    print("ジェネシスブロックを作成中・・・")
    bc.create_genesis()
    for i in range(30):
        print(str(i + 2) + "番目のブロックを生成中・・・")
        bc.add_newblock(i)