diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N1 b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N1 new file mode 100644 index 00000000..d7765fe4 --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N1 @@ -0,0 +1 @@ +70 \ No newline at end of file diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N2 b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N2 new file mode 100644 index 00000000..afbe8472 --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N2 @@ -0,0 +1 @@ +126 \ No newline at end of file diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N3 b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N3 new file mode 100644 index 00000000..dd1ec209 --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N3 @@ -0,0 +1 @@ +132 \ No newline at end of file diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N4 b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N4 new file mode 100644 index 00000000..24af08a4 --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N4 @@ -0,0 +1 @@ +83 \ No newline at end of file diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N5 b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N5 new file mode 100644 index 00000000..9d07aa0d --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N5 @@ -0,0 +1 @@ +111 \ No newline at end of file diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N6 b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N6 new file mode 100644 index 00000000..d7f3668a --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N6 @@ -0,0 +1 @@ +98 \ No newline at end of file diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N7 b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N7 new file mode 100644 index 00000000..e3f1e9b7 --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/N7 @@ -0,0 +1 @@ +80 \ No newline at end of file diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/journal_transaction.txt b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/journal_transaction.txt new file mode 100644 index 00000000..ca0e5208 --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/journal_transaction.txt @@ -0,0 +1,40 @@ +01-03-2024 16:01:01 : N1 a envoyé 10 à N6 +01-03-2024 16:01:01 : N4 a envoyé 10 à N3 +01-03-2024 16:01:01 : N1 a envoyé 4 à N6 +01-03-2024 16:01:01 : N1 a envoyé 9 à N4 +01-03-2024 16:01:01 : N1 a envoyé 9 à N7 +01-03-2024 16:01:01 : N5 a envoyé 6 à N4 +01-03-2024 16:01:01 : N4 a envoyé 1 à N7 +01-03-2024 16:01:01 : N1 a envoyé 5 à N2 +01-03-2024 16:01:01 : N4 a envoyé 10 à N1 +01-03-2024 16:01:01 : N7 a envoyé 2 à N6 +01-03-2024 16:01:01 : N2 a envoyé 5 à N1 +01-03-2024 16:01:01 : N6 a envoyé 7 à N7 +01-03-2024 16:01:01 : N6 a envoyé 7 à N1 +01-03-2024 16:01:01 : N5 a envoyé 2 à N6 +01-03-2024 16:01:01 : N7 a envoyé 6 à N4 +01-03-2024 16:01:01 : N6 a envoyé 7 à N3 +01-03-2024 16:01:01 : N1 a envoyé 2 à N4 +01-03-2024 16:01:01 : N4 a envoyé 8 à N6 +01-03-2024 16:01:01 : N1 a envoyé 3 à N3 +01-03-2024 16:01:01 : N6 a envoyé 3 à N4 +01-03-2024 16:01:19 : N7 a envoyé 10 à N2 +01-03-2024 16:01:19 : N3 a envoyé 7 à N1 +01-03-2024 16:01:19 : N1 a envoyé 2 à N5 +01-03-2024 16:01:19 : N1 a envoyé 9 à N2 +01-03-2024 16:01:19 : N1 a envoyé 1 à N2 +01-03-2024 16:01:19 : N6 a envoyé 1 à N7 +01-03-2024 16:01:19 : N2 a envoyé 1 à N6 +01-03-2024 16:01:19 : N3 a envoyé 9 à N2 +01-03-2024 16:01:19 : N4 a envoyé 6 à N7 +01-03-2024 16:01:19 : N4 a envoyé 6 à N6 +01-03-2024 16:01:19 : N7 a envoyé 8 à N3 +01-03-2024 16:01:19 : N2 a envoyé 10 à N3 +01-03-2024 16:01:19 : N6 a envoyé 2 à N2 +01-03-2024 16:01:19 : N6 a envoyé 8 à N5 +01-03-2024 16:01:19 : N4 a envoyé 2 à N2 +01-03-2024 16:01:19 : N7 a envoyé 9 à N4 +01-03-2024 16:01:19 : N1 a envoyé 5 à N3 +01-03-2024 16:01:19 : N2 a envoyé 5 à N3 +01-03-2024 16:01:19 : N4 a envoyé 9 à N5 +01-03-2024 16:01:19 : N7 a envoyé 9 à N2 diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/transfert.py b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/transfert.py new file mode 100644 index 00000000..cf33964f --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/LACHAINE/transfert.py @@ -0,0 +1,67 @@ +import sys +from datetime import datetime +import random + +def enregistrer_transaction(source,destination,montant): + heure = datetime.now().strftime("%d-%m-%Y %H:%M:%S") + + with open('journal_transaction.txt', 'a') as journal: + journal.write(f"{heure} : {source} a envoyé {montant} à {destination}\n") + +def transfert_montant(source,destination,montant): + + if source == destination: + print("Transaction annulée, l'utilisateur ne peut pas s'envoyer des fonds à lui même") + return + + with open(source,'r') as f_source: + montant_source = int(f_source.read()) + + if montant_source < montant: + print(f"Solde de {source} insuffisant") + return + + with open(destination,'r') as f_destination: + montant_destination= int(f_destination.read()) + + montant_source -= montant + montant_destination += montant + + with open(source,'w') as f_source: + f_source.write(str(montant_source)) + + with open(destination,'w') as f_destination: + f_destination.write(str(montant_destination)) + + enregistrer_transaction(source,destination,montant) + +def generer_random(n): + for _ in range(n): + source = f"N{random.randint(1,7)}" + destination = f"N{random.randint(1,7)}" + + while destination == source: + destination = f"N{random.randint(1,7)}" + + montant = random.randint(1,10) + + try: + transfert_montant(source,destination,montant) + except Exception as e: + print(f"Erreur lors de la transaction : {e}") + + +if __name__ == "__main__": + if len(sys.argv) == 4 : + source = sys.argv[1] + destination = sys.argv[2] + montant = int(sys.argv[3]) + transfert_montant(source,destination,montant) + else: + if len(sys.argv) > 1 : + if sys.argv[1] == "random": + n_transactions = 20 + generer_random(n_transactions) + else: + print("Cas d'usage : python3 transfert.py random") + diff --git a/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/ipfs_id b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/ipfs_id new file mode 100644 index 00000000..1165e032 --- /dev/null +++ b/adventure/BLOCKCHAIN/nathan.piazzi@ynov.com/ipfs_id @@ -0,0 +1 @@ +12D3KooWMMxuuHnTahrVFYAybVd7g1HQ75pGteu7Mcd57hvjjd19