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):
|
def mine(self, leading_zeros):
|
||||||
self.nonce = 0
|
self.nonce = 0
|
||||||
|
|
||||||
if self.previousBlock:
|
|
||||||
self.previousHash = self.previousBlock.blockHash
|
|
||||||
else:
|
|
||||||
self.previousHash = None
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
digest = self.computeHash()
|
digest = self.computeHash()
|
||||||
|
|
||||||
@ -85,16 +80,10 @@ class CBlock:
|
|||||||
# The computed digest of the current block
|
# The computed digest of the current block
|
||||||
# The stored digest of the previous block
|
# The stored digest of the previous block
|
||||||
# return the result of all comparisons as a boolean value
|
# 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):
|
def is_valid_hash(self):
|
||||||
if self.previousBlock:
|
if(self.previousBlock == None):
|
||||||
self.previousHash = self.previousBlock.computeHash()
|
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