-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: onSlotFinalized include all previous slots. #1335
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Eugene Panteleymonchuk <[email protected]>
This was
linked to
issues
Mar 25, 2024
VmMad
approved these changes
Mar 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works nice! Only suggestion is renaming some variables :)
Comment on lines
+262
to
+288
const slotsBefore = Array.from(confirmedBlocksBySlot.keys()); | ||
|
||
const slots = [...slotsBefore, slotFinalized]; | ||
|
||
const blocks = []; | ||
for (const slot of slots) { | ||
const blockIds = confirmedBlocksBySlot.get(slot); | ||
if (blockIds) { | ||
blocks.push(...blockIds); | ||
} | ||
} | ||
|
||
if (blocks?.length) { | ||
blocks.forEach((blockId) => { | ||
const selectedColor = getBlockColorByState(themeMode, "finalized"); | ||
if (selectedColor) { | ||
updateBlockIdToMetadata(blockId, { | ||
state: "finalized", | ||
color: selectedColor, | ||
}); | ||
updateBlockColor(blockId, selectedColor); | ||
} | ||
}); | ||
} | ||
|
||
for (const slot of slots) { | ||
removeConfirmedBlocksSlot(slot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks nice, I suggest renaming the variables a bit so it is more easy to understand :)
const previousFinalizedSlots = Array.from(confirmedBlocksBySlot.keys());
const allFinalizedSlots = [...previousFinalizedSlots, slotFinalized];
const confirmedBlocks = [];
for (const slot of allFinalizedSlots) {
const confirmedBlockIds = confirmedBlocksBySlot.get(slot);
if (confirmedBlockIds) {
confirmedBlocks.push(...confirmedBlockIds);
}
}
if (confirmedBlocks?.length) {
confirmedBlocks.forEach((blockId) => {
const finalizedBlockColor = getBlockColorByState(themeMode, "finalized");
if (finalizedBlockColor) {
updateBlockIdToMetadata(blockId, {
state: "finalized",
color: finalizedBlockColor,
});
updateBlockColor(blockId, finalizedBlockColor);
}
});
}
for (const slot of allFinalizedSlots) {
removeConfirmedBlocksSlot(slot);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of change
Mark all related blocks as finalized when we get slot index from onSlotFinalized handler.
Closes #1334
Type of change
How the change has been tested
After handle onSlotFinalized function blocks for current slot Index and before index need to be marked as "finalized"
Change checklist
Add an
x
to the boxes that are relevant to your changes, and delete any items that are not.