-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathboilerplate.py
More file actions
74 lines (55 loc) · 1.78 KB
/
boilerplate.py
File metadata and controls
74 lines (55 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
@Author: ADD YOUR NAME HERE
@Date Created: ADD DATE CREATED
@Title: BLOCKCHAIN SIMULATOR
"""
# Importing modules
import hashlib # hashlib for hashing algorithms
import datetime as date # datetime for dates
import random # random for randomizing numbers for transactions
class Block():
"""
A certain block consists of the following entities:
+ Block height
+ Timestamp
+ Previous block hash
+ Transactions
+ Transactions counter
"""
def __init__(self, height, timestamp, prev_hash, txs):
pass
#-------------------------------------------------------------------------------------
"""
Generates hash using SHA-256 algorithm
"""
def hashing(self, s):
pass
#-------------------------------------------------------------------------------------
"""
Creates hash for the block
"""
def hash_block(self):
pass
#-------------------------------------------------------------------------------------
"""
Generates Merkle Root Hash for all transactions
"""
def merkle_root_hash(self, txs):
pass
"""
Creates the genesis block, i.e. the first block of the blockchain
"""
def create_genesis_block():
# Manually construct a block with height zero and arbitrary previous hash
pass
"""
Defines properties for the next block in the blockchain and returns Block object
"""
def next_block(last_block):
pass
if __name__=="__main__":
# Create blockchain as a list and add the genesis block
# Let's add 20 blocks to the chain
# We will be mining 20 blocks
# Showing block information
pass