Skip to content

Conversation

@zeusoo001
Copy link
Contributor

What does this PR do?
Optimize the event cache solid block ID update logic.

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

BlockCapsule.BlockId headBlockId = head.getBlockId();
if (blockEvent.getSolidId().getNum() <= headBlockId.getNum()) {
solidId = blockEvent.getSolidId();
} else if (blockEvent.getBlockId().equals(headBlockId)) {
Copy link
Contributor

@bladehan1 bladehan1 Jan 29, 2026

Choose a reason for hiding this comment

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

From the perspective of the blockEvent event:
blockEvent.getBlockId().getNum() >= blockEvent.getSolidId().getNum()
From the perspective of the head assignment:
head.getBlockId().getNum() >= blockEvent.getBlockId().getNum()

Therefore, it should always be true:
headBlockId.getNum()>= blockEvent.getBlockId().getNum()>= blockEvent.getSolidId().getNum()

That is,
headBlockId.getNum()>= blockEvent.getSolidId().getNum()

In any case, what situation might cause it to not be true?

Copy link
Contributor

Choose a reason for hiding this comment

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

blockEvent.getSolidId() represents the current solidified block height. For example, if 218 blocks are currently synchronized, when loading the 100th block, the current solidified block height might be 200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants