From 34420a9a9eb0680432e396af8ebe19d10759c6f0 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 13:53:25 +0000 Subject: [PATCH] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 1fd4140 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- blockchain/chain.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/blockchain/chain.py b/blockchain/chain.py index ad5ad80d5..ee2bc218f 100644 --- a/blockchain/chain.py +++ b/blockchain/chain.py @@ -1,23 +1,35 @@ import hashlib + class Blockchain: def __init__(self): self.chain = [self.create_genesis_block()] self.difficulty = 2 def create_genesis_block(self): - return Block(0, '0' * 64, int(time.time()), 'Genesis Block', self.calculate_hash(0, '0' * 64, int(time.time()), 'Genesis Block')) + return Block( + 0, + "0" * 64, + int(time.time()), + "Genesis Block", + self.calculate_hash(0, "0" * 64, int(time.time()), "Genesis Block"), + ) def calculate_hash(self, index, previous_hash, timestamp, data): value = str(index) + str(previous_hash) + str(timestamp) + str(data) - return hashlib.sha256(value.encode('utf-8')).hexdigest() + return hashlib.sha256(value.encode("utf-8")).hexdigest() def is_chain_valid(self, chain): for i in range(1, len(chain)): current_block = chain[i] previous_block = chain[i - 1] - if current_block.hash != self.calculate_hash(current_block.index, current_block.previous_hash, current_block.timestamp, current_block.data): + if current_block.hash != self.calculate_hash( + current_block.index, + current_block.previous_hash, + current_block.timestamp, + current_block.data, + ): return False if current_block.previous_hash != previous_block.hash: @@ -26,8 +38,15 @@ def is_chain_valid(self, chain): return True def add_block(self, data): - new_block = Block(len(self.chain), self.chain[-1].hash, int(time.time()), data, None) - new_block.hash = self.calculate_hash(new_block.index, new_block.previous_hash, new_block.timestamp, new_block.data) + new_block = Block( + len(self.chain), self.chain[-1].hash, int(time.time()), data, None + ) + new_block.hash = self.calculate_hash( + new_block.index, + new_block.previous_hash, + new_block.timestamp, + new_block.data, + ) self.chain.append(new_block) def replace_chain(self, chain):