Author SHA1 Message Date
marc afab0fe059 started the fix 2022-02-23 21:59:45 +01:00
3 changed files with 7 additions and 27 deletions
-9
View File
@@ -1,9 +0,0 @@
start:
./app.py -p 8000
update:
pipenv update
pipenv lock -r > requirements.txt
build: update
docker-compose build node
push: build
docker-compose push node
+6
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env python
"""Block chain according to me."""
import hashlib
from time import time
@@ -10,6 +11,7 @@ DIFFICULTY = 4
class Block:
"""Block according to me."""
def __init__(self, index, timestamp, transactions, previous_hash, proof):
self.index = index
self.timestamp = timestamp
@@ -19,6 +21,7 @@ class Block:
self.hash = self.hash()
def hash(self):
"""Hash a block using sha256."""
data = self.__dict__
data["transactions"] = [t.__dict__ for t in self.transactions]
block_string = json.dumps(data, sort_keys=True).encode()
@@ -29,16 +32,19 @@ class Block:
class Transaction:
"""Transaction of Samy coin."""
def __init__(self, sender, recipient, amount):
self.sender = sender
self.recipient = recipient
self.amount = amount
def __str__(self):
"""String representation of a transaction."""
return f"FROM: {self.sender} TO: {self.recipient} AMOUNT: {self.amount}"
class Blockchain:
"""Blockchain"""
def __init__(self):
self.blocks = []
self.blocks.append(self.create_first_block())
+1 -18
View File
@@ -1,19 +1,2 @@
#
# These requirements were autogenerated by pipenv
# To regenerate from the project's Pipfile, run:
#
# pipenv lock --requirements
#
-i https://pypi.org/simple
certifi==2021.10.8
charset-normalizer==2.0.12; python_version >= '3'
click==8.0.4; python_version >= '3.6'
flask==2.0.2
idna==3.3; python_version >= '3'
itsdangerous==2.1.0; python_version >= '3.7'
jinja2==3.0.3; python_version >= '3.6'
markupsafe==2.1.0; python_version >= '3.7'
Flask==2.0.2
requests==2.27.1
urllib3==1.26.8; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
werkzeug==2.0.3; python_version >= '3.6'