Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion hathor/consensus/block_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ def update_voided_info(self, block: Block) -> None:
if common_block not in heads:
self.context.mark_as_reorg(common_block)
else:
storage.update_best_block_tips_cache([not_none(blk.hash) for blk in heads])
best_block_tips = [not_none(blk.hash) for blk in heads]
best_block_tips.append(not_none(block.hash))
storage.update_best_block_tips_cache(best_block_tips)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just set to None and let the next call cache it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way is fine for me. I wish we can get rid of this cache in the future. Will we even need it if we don't have best block ties, because even for sync-v1 the block height index would have a ready O(1) (or at least however fast best_blocks[-1] is) response?

if not meta.voided_by:
self.context.mark_as_reorg(common_block)

Expand Down
3 changes: 2 additions & 1 deletion tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def assertTipsEqualSyncV2(self, manager1, manager2, *, strict_sync_v2_indexes=Tr
# best block (from height index)
b1 = manager1.tx_storage.indexes.height.get_tip()
b2 = manager2.tx_storage.indexes.height.get_tip()
self.assertEqual(b1, b2)
self.assertIn(b1, s2)
self.assertIn(b2, s1)

def assertConsensusEqual(self, manager1, manager2):
_, enable_sync_v2 = self._syncVersionFlags()
Expand Down