feat(event): optimize the event cache solid block ID update logic#6531
Conversation
| BlockCapsule.BlockId headBlockId = head.getBlockId(); | ||
| if (blockEvent.getSolidId().getNum() <= headBlockId.getNum()) { | ||
| solidId = blockEvent.getSolidId(); | ||
| } else if (blockEvent.getBlockId().equals(headBlockId)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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:
Follow up
Extra details