Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More PEP formatting.
  • Loading branch information
brannondorsey committed Mar 15, 2018
commit 3b6659f40c17dd70dc6ef61464b16fe8b86df736
10 changes: 5 additions & 5 deletions blockchain_parser/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __getBlockIndexes(self, index):
if self.indexPath != index:
db = plyvel.DB(index, compression=None)
self.blockIndexes = [DBBlockIndex(format_hash(k[1:]), v)
for k, v in db.iterator() if k[0] == ord('b')]
for k, v in db.iterator() if k[0] == ord('b')]
db.close()
self.blockIndexes.sort(key=lambda x: x.height)
self.indexPath = index
Expand Down Expand Up @@ -144,7 +144,7 @@ def _index_confirmed(self, chain_indexes, num_confirmations=6):
# we are ready to make a decesion on whether or not the block
# belongs to a fork or the main chain
if len(chain) == num_confirmations:
if first_block.hash in chain:
if first_block.hash in chain:
return True
else:
return False
Expand Down Expand Up @@ -187,8 +187,8 @@ def get_ordered_blocks(self, index, start=0, end=None, cache=None):
if blockIdx.height == last_height:

# loop through future blocks until we find a chain 6 blocks
# long that includes this block. If we can't find one remove
# this block as it is invalid
# long that includes this block. If we can't find one
# remove this block as it is invalid
if self._index_confirmed(blockIndexes[i:]):

# if this block is confirmed, the unconfirmed block is
Expand All @@ -202,7 +202,7 @@ def get_ordered_blocks(self, index, start=0, end=None, cache=None):
last_height = blockIdx.height

# filter out the orphan blocks, so we are left only with block indexes
# that have been confirmed
# that have been confirmed
# (or are new enough that they haven't yet been confirmed)
blockIndexes = list(filter(lambda block: block.hash not in orphans, blockIndexes))

Expand Down