@@ -23,42 +23,33 @@ def getCurrentBlock(self):
23
23
currentBlock = self .chain [- 1 ]
24
24
return currentBlock
25
25
26
- # def addNewBlock(self, sender, receiver, amount):
27
- # currentBlock = self.getCurrentBlock()
28
- # currTime = str(datetime.now())
29
- # newTransaction = Transaction(sender, receiver, amount, currTime)
30
- # newBlock = Block(currTime, newTransaction, currentBlock.currentHash)
31
- # newBlock.mineBlock(BlockChain.difficulty)
32
- # self.chain.append(newBlock)
33
-
34
26
def minePendingTransactions (self , minerRewardAddress ):
35
27
currTime = str (datetime .now ())
36
28
newBlock = Block (currTime , self .pendingTransactions )
37
29
newBlock .mineBlock (BlockChain .difficulty )
38
30
self .chain .append (newBlock )
39
- self .pendingTransactions = [Transaction (None , minerRewardAddress , self .miningReward )]
31
+ self .pendingTransactions = [Transaction (
32
+ None , minerRewardAddress , self .miningReward )]
40
33
41
34
def addTransaction (self , newTransaction ):
42
35
self .pendingTransactions .append (newTransaction )
43
-
44
36
45
37
def getBalanceMiner (self , minerAddress ):
46
- balance = 0 ;
38
+ balance = 0
47
39
for block in self .chain :
48
40
for trans in block .transactions :
49
41
if trans .getSenderAddress () == minerAddress :
50
42
balance -= trans .amount
51
43
if trans .getReceiverAddress () == minerAddress :
52
44
balance += trans .amount
53
45
return balance
54
-
46
+
55
47
def getAllTransaction (self ):
56
48
for trans in self .pendingTransactions :
57
49
print (trans .getSenderAddress ())
58
50
print (trans .getReceiverAddress ())
59
- print (trans .getAmount (), "\n " )
51
+ print (trans .getAmount (), "\n " )
60
52
61
-
62
53
def verifyIntegity (self ):
63
54
for i in range (1 , len (self .chain )):
64
55
prevBlock = self .chain [i - 1 ]
0 commit comments