5
def __init__(self, index, previous_hash,
transactions, timestamp, nonce=0):
7
self.previous_hash = previous_hash
8
self.transactions = transactions
9
self.timestamp = timestamp
12
def compute_hash(self):
13
block_string = json.dumps(self.__dict__,
sort_keys=True)
14
returnhashlib.sha256(block_string.encode()).hexdigest()