forked from STI/Astroport.ONE
Merge pull request #90 from gaetancorin/master
add blockchain python on gc space
This commit is contained in:
commit
c0333f9b28
20
adventure/BLOCKCHAIN/gaetan.corin@ynov.com/FENETRE/block.txt
Normal file
20
adventure/BLOCKCHAIN/gaetan.corin@ynov.com/FENETRE/block.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
1709306506 N8.txt= -25
|
||||||
|
1709306506 N2.txt= +25
|
||||||
|
1709306506 N3.txt= -1
|
||||||
|
1709306506 N10.txt= +1
|
||||||
|
1709306506 N7.txt= -43
|
||||||
|
1709306506 N8.txt= +43
|
||||||
|
1709306506 N3.txt= -14
|
||||||
|
1709306506 N10.txt= +14
|
||||||
|
1709306506 N9.txt= -48
|
||||||
|
1709306506 N6.txt= +48
|
||||||
|
1709306506 N10.txt= -37
|
||||||
|
1709306506 N9.txt= +37
|
||||||
|
1709306506 N4.txt= -21
|
||||||
|
1709306506 N5.txt= +21
|
||||||
|
1709306506 N4.txt= -15
|
||||||
|
1709306506 N7.txt= +15
|
||||||
|
1709306506 N6.txt= -47
|
||||||
|
1709306506 N3.txt= +47
|
||||||
|
1709306506 N6.txt= -1
|
||||||
|
1709306506 N3.txt= +1
|
200
adventure/BLOCKCHAIN/gaetan.corin@ynov.com/FENETRE/chaine.txt
Normal file
200
adventure/BLOCKCHAIN/gaetan.corin@ynov.com/FENETRE/chaine.txt
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
1709306497 N2.txt= -6
|
||||||
|
1709306497 N4.txt= +6
|
||||||
|
1709306497 N2.txt= -23
|
||||||
|
1709306497 N7.txt= +23
|
||||||
|
1709306497 N2.txt= -31
|
||||||
|
1709306497 N8.txt= +31
|
||||||
|
1709306497 N3.txt= -42
|
||||||
|
1709306497 N8.txt= +42
|
||||||
|
1709306497 N4.txt= -16
|
||||||
|
1709306497 N8.txt= +16
|
||||||
|
1709306497 N5.txt= -9
|
||||||
|
1709306497 N3.txt= +9
|
||||||
|
1709306497 N9.txt= -27
|
||||||
|
1709306497 N10.txt= +27
|
||||||
|
1709306497 N8.txt= -29
|
||||||
|
1709306497 N10.txt= +29
|
||||||
|
1709306497 N8.txt= -19
|
||||||
|
1709306497 N4.txt= +19
|
||||||
|
1709306497 N1.txt= -23
|
||||||
|
1709306497 N9.txt= +23
|
||||||
|
1709306498 N7.txt= -34
|
||||||
|
1709306498 N5.txt= +34
|
||||||
|
1709306498 N7.txt= -8
|
||||||
|
1709306498 N4.txt= +8
|
||||||
|
1709306498 N6.txt= -46
|
||||||
|
1709306498 N4.txt= +46
|
||||||
|
1709306498 N9.txt= -18
|
||||||
|
1709306498 N5.txt= +18
|
||||||
|
1709306498 N2.txt= -40
|
||||||
|
1709306498 N3.txt= +40
|
||||||
|
1709306498 N1.txt= -42
|
||||||
|
1709306498 N9.txt= +42
|
||||||
|
1709306498 N7.txt= -21
|
||||||
|
1709306498 N10.txt= +21
|
||||||
|
1709306498 N4.txt= -27
|
||||||
|
1709306498 N8.txt= +27
|
||||||
|
1709306498 N10.txt= -33
|
||||||
|
1709306498 N1.txt= +33
|
||||||
|
1709306498 N3.txt= -7
|
||||||
|
1709306498 N10.txt= +7
|
||||||
|
1709306499 N7.txt= -26
|
||||||
|
1709306499 N6.txt= +26
|
||||||
|
1709306499 N5.txt= -1
|
||||||
|
1709306499 N3.txt= +1
|
||||||
|
1709306499 N7.txt= -49
|
||||||
|
1709306499 N10.txt= +49
|
||||||
|
1709306499 N9.txt= -26
|
||||||
|
1709306499 N3.txt= +26
|
||||||
|
1709306499 N6.txt= -11
|
||||||
|
1709306499 N10.txt= +11
|
||||||
|
1709306499 N5.txt= -19
|
||||||
|
1709306499 N9.txt= +19
|
||||||
|
1709306499 N6.txt= -8
|
||||||
|
1709306499 N3.txt= +8
|
||||||
|
1709306499 N3.txt= -22
|
||||||
|
1709306499 N5.txt= +22
|
||||||
|
1709306499 N8.txt= -42
|
||||||
|
1709306499 N5.txt= +42
|
||||||
|
1709306499 N7.txt= -47
|
||||||
|
1709306499 N6.txt= +47
|
||||||
|
1709306500 N7.txt= -33
|
||||||
|
1709306500 N5.txt= +33
|
||||||
|
1709306500 N3.txt= -41
|
||||||
|
1709306500 N7.txt= +41
|
||||||
|
1709306500 N6.txt= -25
|
||||||
|
1709306500 N3.txt= +25
|
||||||
|
1709306500 N1.txt= -22
|
||||||
|
1709306500 N8.txt= +22
|
||||||
|
1709306500 N7.txt= -4
|
||||||
|
1709306500 N8.txt= +4
|
||||||
|
1709306500 N2.txt= -47
|
||||||
|
1709306500 N3.txt= +47
|
||||||
|
1709306500 N1.txt= -30
|
||||||
|
1709306500 N9.txt= +30
|
||||||
|
1709306500 N10.txt= -43
|
||||||
|
1709306500 N1.txt= +43
|
||||||
|
1709306500 N6.txt= -11
|
||||||
|
1709306500 N1.txt= +11
|
||||||
|
1709306500 N6.txt= -21
|
||||||
|
1709306500 N8.txt= +21
|
||||||
|
1709306501 N6.txt= -16
|
||||||
|
1709306501 N8.txt= +16
|
||||||
|
1709306501 N5.txt= -28
|
||||||
|
1709306501 N6.txt= +28
|
||||||
|
1709306501 N8.txt= -29
|
||||||
|
1709306501 N4.txt= +29
|
||||||
|
1709306501 N7.txt= -41
|
||||||
|
1709306501 N10.txt= +41
|
||||||
|
1709306501 N3.txt= -48
|
||||||
|
1709306501 N6.txt= +48
|
||||||
|
1709306501 N2.txt= -12
|
||||||
|
1709306501 N9.txt= +12
|
||||||
|
1709306501 N5.txt= -18
|
||||||
|
1709306501 N4.txt= +18
|
||||||
|
1709306501 N1.txt= -27
|
||||||
|
1709306501 N2.txt= +27
|
||||||
|
1709306501 N9.txt= -20
|
||||||
|
1709306501 N2.txt= +20
|
||||||
|
1709306501 N4.txt= -30
|
||||||
|
1709306501 N8.txt= +30
|
||||||
|
1709306502 N5.txt= -26
|
||||||
|
1709306502 N10.txt= +26
|
||||||
|
1709306502 N10.txt= -39
|
||||||
|
1709306502 N6.txt= +39
|
||||||
|
1709306502 N10.txt= -18
|
||||||
|
1709306502 N4.txt= +18
|
||||||
|
1709306502 N1.txt= -7
|
||||||
|
1709306502 N3.txt= +7
|
||||||
|
1709306502 N10.txt= -20
|
||||||
|
1709306502 N2.txt= +20
|
||||||
|
1709306502 N2.txt= -42
|
||||||
|
1709306502 N5.txt= +42
|
||||||
|
1709306502 N6.txt= -7
|
||||||
|
1709306502 N2.txt= +7
|
||||||
|
1709306502 N3.txt= -36
|
||||||
|
1709306502 N1.txt= +36
|
||||||
|
1709306502 N7.txt= -30
|
||||||
|
1709306502 N10.txt= +30
|
||||||
|
1709306502 N2.txt= -15
|
||||||
|
1709306502 N6.txt= +15
|
||||||
|
1709306503 N4.txt= -13
|
||||||
|
1709306503 N8.txt= +13
|
||||||
|
1709306503 N2.txt= -28
|
||||||
|
1709306503 N9.txt= +28
|
||||||
|
1709306503 N10.txt= -37
|
||||||
|
1709306503 N1.txt= +37
|
||||||
|
1709306503 N6.txt= -8
|
||||||
|
1709306503 N1.txt= +8
|
||||||
|
1709306503 N10.txt= -39
|
||||||
|
1709306503 N6.txt= +39
|
||||||
|
1709306503 N1.txt= -20
|
||||||
|
1709306503 N3.txt= +20
|
||||||
|
1709306503 N10.txt= -33
|
||||||
|
1709306503 N4.txt= +33
|
||||||
|
1709306503 N5.txt= -34
|
||||||
|
1709306503 N9.txt= +34
|
||||||
|
1709306503 N6.txt= -17
|
||||||
|
1709306503 N4.txt= +17
|
||||||
|
1709306503 N4.txt= -41
|
||||||
|
1709306503 N5.txt= +41
|
||||||
|
1709306504 N3.txt= -42
|
||||||
|
1709306504 N10.txt= +42
|
||||||
|
1709306504 N2.txt= -48
|
||||||
|
1709306504 N1.txt= +48
|
||||||
|
1709306504 N10.txt= -1
|
||||||
|
1709306504 N2.txt= +1
|
||||||
|
1709306504 N8.txt= -47
|
||||||
|
1709306504 N5.txt= +47
|
||||||
|
1709306504 N4.txt= -4
|
||||||
|
1709306504 N1.txt= +4
|
||||||
|
1709306504 N7.txt= -36
|
||||||
|
1709306504 N10.txt= +36
|
||||||
|
1709306504 N8.txt= -43
|
||||||
|
1709306504 N5.txt= +43
|
||||||
|
1709306504 N2.txt= -1
|
||||||
|
1709306504 N10.txt= +1
|
||||||
|
1709306504 N4.txt= -48
|
||||||
|
1709306504 N10.txt= +48
|
||||||
|
1709306504 N6.txt= -35
|
||||||
|
1709306504 N7.txt= +35
|
||||||
|
1709306505 N9.txt= -8
|
||||||
|
1709306505 N2.txt= +8
|
||||||
|
1709306505 N9.txt= -4
|
||||||
|
1709306505 N2.txt= +4
|
||||||
|
1709306505 N7.txt= -26
|
||||||
|
1709306505 N10.txt= +26
|
||||||
|
1709306505 N10.txt= -21
|
||||||
|
1709306505 N7.txt= +21
|
||||||
|
1709306505 N8.txt= -31
|
||||||
|
1709306505 N7.txt= +31
|
||||||
|
1709306505 N8.txt= -11
|
||||||
|
1709306505 N10.txt= +11
|
||||||
|
1709306505 N1.txt= -22
|
||||||
|
1709306505 N6.txt= +22
|
||||||
|
1709306505 N3.txt= -16
|
||||||
|
1709306505 N5.txt= +16
|
||||||
|
1709306505 N8.txt= -19
|
||||||
|
1709306505 N3.txt= +19
|
||||||
|
1709306505 N6.txt= -10
|
||||||
|
1709306505 N4.txt= +10
|
||||||
|
1709306506 N8.txt= -25
|
||||||
|
1709306506 N2.txt= +25
|
||||||
|
1709306506 N3.txt= -1
|
||||||
|
1709306506 N10.txt= +1
|
||||||
|
1709306506 N7.txt= -43
|
||||||
|
1709306506 N8.txt= +43
|
||||||
|
1709306506 N3.txt= -14
|
||||||
|
1709306506 N10.txt= +14
|
||||||
|
1709306506 N9.txt= -48
|
||||||
|
1709306506 N6.txt= +48
|
||||||
|
1709306506 N10.txt= -37
|
||||||
|
1709306506 N9.txt= +37
|
||||||
|
1709306506 N4.txt= -21
|
||||||
|
1709306506 N5.txt= +21
|
||||||
|
1709306506 N4.txt= -15
|
||||||
|
1709306506 N7.txt= +15
|
||||||
|
1709306506 N6.txt= -47
|
||||||
|
1709306506 N3.txt= +47
|
||||||
|
1709306506 N6.txt= -1
|
||||||
|
1709306506 N3.txt= +1
|
80
adventure/BLOCKCHAIN/gaetan.corin@ynov.com/FENETRE/script.py
Normal file
80
adventure/BLOCKCHAIN/gaetan.corin@ynov.com/FENETRE/script.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import os
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
|
||||||
|
folder_user = './../LACHAINE'
|
||||||
|
|
||||||
|
def genesis():
|
||||||
|
print("Lancement de la chaine")
|
||||||
|
with open("chaine.txt", "w") as fichier:
|
||||||
|
fichier.write("")
|
||||||
|
|
||||||
|
def get_users_account():
|
||||||
|
if os.path.isdir(folder_user):
|
||||||
|
users_name = os.listdir(folder_user)
|
||||||
|
return users_name
|
||||||
|
|
||||||
|
def regeneration_account(users_name):
|
||||||
|
for user in users_name:
|
||||||
|
with open(os.path.join(folder_user, user), "w") as fichier:
|
||||||
|
fichier.write("N=100")
|
||||||
|
|
||||||
|
def create_block(users_name):
|
||||||
|
with open("block.txt", "w") as fichier:
|
||||||
|
fichier.write("")
|
||||||
|
for i in range(10):
|
||||||
|
transaction = create_transaction(users_name)
|
||||||
|
|
||||||
|
def create_transaction(users_name):
|
||||||
|
debtor = random.choice(users_name)
|
||||||
|
creditor = random.choice(users_name)
|
||||||
|
while debtor == creditor:
|
||||||
|
creditor = random.choice(users_name)
|
||||||
|
payment = random.randint(1, 50)
|
||||||
|
print('debtor:', debtor, 'creditor:', creditor, 'payment:', payment)
|
||||||
|
debit_value(debtor, payment)
|
||||||
|
credit_value(creditor, payment)
|
||||||
|
with open("block.txt", "a") as fichier:
|
||||||
|
timestamp = int(time.time())
|
||||||
|
fichier.write(str(timestamp)+' '+debtor+"= -"+str(payment)+'\n')
|
||||||
|
fichier.write(str(timestamp)+' '+creditor+"= +"+str(payment)+'\n')
|
||||||
|
|
||||||
|
def debit_value(debtor, payment):
|
||||||
|
with open(os.path.join(folder_user, debtor), "r") as fichier:
|
||||||
|
account = fichier.read()
|
||||||
|
account_value = int(account.split("=")[1])
|
||||||
|
new_account_value = "N="+ str(account_value - payment)
|
||||||
|
with open(os.path.join(folder_user, debtor), "w") as fichier:
|
||||||
|
fichier.write(new_account_value)
|
||||||
|
|
||||||
|
|
||||||
|
def credit_value(creditor, payment):
|
||||||
|
with open(os.path.join(folder_user, creditor), "r") as fichier:
|
||||||
|
account = fichier.read()
|
||||||
|
account_value = int(account.split("=")[1])
|
||||||
|
new_account_value = "N="+ str(account_value + payment)
|
||||||
|
with open(os.path.join(folder_user, creditor), "w") as fichier:
|
||||||
|
fichier.write(new_account_value)
|
||||||
|
|
||||||
|
|
||||||
|
def get_account_value(user):
|
||||||
|
path = os.path.join(folder_user, user)
|
||||||
|
with open(path, "r") as fichier:
|
||||||
|
contenu_lu = fichier.read()
|
||||||
|
print(user, contenu_lu)
|
||||||
|
|
||||||
|
def push_to_chaine():
|
||||||
|
with open("block.txt", "r") as fichier:
|
||||||
|
block = fichier.read()
|
||||||
|
with open("chaine.txt", "a") as fichier:
|
||||||
|
fichier.write(block)
|
||||||
|
|
||||||
|
genesis()
|
||||||
|
users_name = get_users_account()
|
||||||
|
regeneration_account(users_name)
|
||||||
|
for i in range(10):
|
||||||
|
time.sleep(1)
|
||||||
|
create_block(users_name)
|
||||||
|
push_to_chaine()
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
N=127
|
@ -0,0 +1 @@
|
|||||||
|
N=199
|
@ -0,0 +1 @@
|
|||||||
|
N=-81
|
@ -0,0 +1 @@
|
|||||||
|
N=81
|
@ -0,0 +1 @@
|
|||||||
|
N=89
|
@ -0,0 +1 @@
|
|||||||
|
N=324
|
@ -0,0 +1 @@
|
|||||||
|
N=149
|
@ -0,0 +1 @@
|
|||||||
|
N=-132
|
@ -0,0 +1 @@
|
|||||||
|
N=70
|
@ -0,0 +1 @@
|
|||||||
|
N=174
|
Loading…
Reference in New Issue
Block a user