Merge branch 'main' of git.aterve.com:Spekulaas/Blockchain_School
This commit is contained in:
commit
8edf706e22
@ -64,11 +64,6 @@ class CBlock:
|
||||
def mine(self, leading_zeros):
|
||||
self.nonce = 0
|
||||
|
||||
if self.previousBlock:
|
||||
self.previousHash = self.previousBlock.blockHash
|
||||
else:
|
||||
self.previousHash = None
|
||||
|
||||
while True:
|
||||
digest = self.computeHash()
|
||||
|
||||
@ -85,16 +80,10 @@ class CBlock:
|
||||
# The computed digest of the current block
|
||||
# The stored digest of the previous block
|
||||
# return the result of all comparisons as a boolean value
|
||||
# def is_valid_hash(self):
|
||||
# if(self.previousBlock == None):
|
||||
# return True
|
||||
|
||||
# if(self.computeHash() != self.blockHash or self.previousBlock.blockHash != self.previousBlock.computeHash()):
|
||||
# return False
|
||||
# return self.previousBlock.is_valid_hash()
|
||||
|
||||
def is_valid_hash(self):
|
||||
if self.previousBlock:
|
||||
self.previousHash = self.previousBlock.computeHash()
|
||||
if(self.previousBlock == None):
|
||||
return True
|
||||
|
||||
return self.computeHash() == self.blockHash
|
||||
if(self.computeHash() != self.blockHash or self.previousBlock.blockHash != self.previousBlock.computeHash()):
|
||||
return False
|
||||
return self.previousBlock.is_valid_hash()
|
Loading…
x
Reference in New Issue
Block a user