ldhldh commited on
Commit
981cbed
β€’
1 Parent(s): 96906d9

Update Blockchain.py

Browse files
Files changed (1) hide show
  1. 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)