Spaces:
Running
Running
Update Blockchain.py
Browse files- Blockchain.py +6 -0
Blockchain.py
CHANGED
@@ -18,6 +18,9 @@ class Blockchain:
|
|
18 |
:param previous_hash: μ΄μ λΈλ‘μ ν΄μ κ°
|
19 |
:return: μλ‘ μμ±λ λΈλ‘
|
20 |
"""
|
|
|
|
|
|
|
21 |
block = {
|
22 |
'index': len(self.chain) + 1,
|
23 |
'timestamp': time(),
|
@@ -41,6 +44,7 @@ class Blockchain:
|
|
41 |
|
42 |
return: ν΄λΉ νΈλμμ
μ ν¬ν¨ν λΈλ‘μ μΈλ±μ€
|
43 |
"""
|
|
|
44 |
transaction = {
|
45 |
'id': id,
|
46 |
'kind': kind,
|
@@ -57,6 +61,8 @@ class Blockchain:
|
|
57 |
else:
|
58 |
# inference μμ² μ μ°¨κ°
|
59 |
self.user_wallets[id] -= 1
|
|
|
|
|
60 |
elif kind == "add":
|
61 |
if id not in self.user_gpus:
|
62 |
self.user_gpus[id] = int(data)
|
|
|
18 |
:param previous_hash: μ΄μ λΈλ‘μ ν΄μ κ°
|
19 |
:return: μλ‘ μμ±λ λΈλ‘
|
20 |
"""
|
21 |
+
for id, mem in self.user_gpus.items():
|
22 |
+
self.user_wallets[id] += mem//2
|
23 |
+
|
24 |
block = {
|
25 |
'index': len(self.chain) + 1,
|
26 |
'timestamp': time(),
|
|
|
44 |
|
45 |
return: ν΄λΉ νΈλμμ
μ ν¬ν¨ν λΈλ‘μ μΈλ±μ€
|
46 |
"""
|
47 |
+
|
48 |
transaction = {
|
49 |
'id': id,
|
50 |
'kind': kind,
|
|
|
61 |
else:
|
62 |
# inference μμ² μ μ°¨κ°
|
63 |
self.user_wallets[id] -= 1
|
64 |
+
if self.user_wallets[id]<0:
|
65 |
+
self.user_wallets[id] = 0
|
66 |
elif kind == "add":
|
67 |
if id not in self.user_gpus:
|
68 |
self.user_gpus[id] = int(data)
|