mistake ex3
This commit is contained in:
parent
e3e587a74e
commit
3a411c2819
@ -63,6 +63,12 @@ class CBlock:
|
|||||||
# Make sure to compute the hash value of the current block and store it properly
|
# Make sure to compute the hash value of the current block and store it properly
|
||||||
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()
|
||||||
|
|
||||||
@ -79,8 +85,16 @@ 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 == None:
|
if self.previousBlock:
|
||||||
return True
|
self.previousHash = self.previousBlock.computeHash()
|
||||||
|
|
||||||
return self.computeHash() == self.blockHash
|
return self.computeHash() == self.blockHash
|
Loading…
x
Reference in New Issue
Block a user