-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashed-block.py
More file actions
46 lines (39 loc) · 919 Bytes
/
hashed-block.py
File metadata and controls
46 lines (39 loc) · 919 Bytes
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
import hashlib, pickle
top_block = {
'transacion' : [
{
'from' : 'Jace',
'to' : 'Lucky',
'amount' : 100
},
{
'from' : 'Mula',
'to' : 'Jace',
'amount' : 150
},
{
'from' : 'Lucky',
'to' : 'Innocent',
'amount' : 90
},
],
'last_block' : n.hexdigest(),
'nonce' : 0
}
pickle.dumps(top_block)
n = hashlib.sha3_256()
n.update(pickle.dumps(top_block())
n.digest()
n.hexdigest()
difficulty = 1
difficulty_string = ''.join(['0' for x in range(difficulty)])
print(difficulty_string)
nonce = 1
top_block['nonce'] = 1
m = hashlib.sha3_256()
while m.hexdigest()[:difficulty] != difficulty_string:
nonce += 1
top_block['nonce'] = nonce
m = hashlib.sha3_256()
m.update(pickle.dumps(top_block))
print(nonce, m,.hexdigest())