This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
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.
In-Memory Blockwatcher Syncing #857
In-Memory Blockwatcher Syncing #857
Changes from 8 commits
390b1dc
a794d50
8b4f762
9b26aba
63caae9
ad68771
e09a8cd
fa71b86
09cdaa5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This function returns false if
len(events) == 0 || lastStoredHeader == nil
, butlen(events)
can't be since we would have returned in line 301 if so. I think that iflastStoredHeader
isnil
in line 242 (old) / 256 (new), then it will still be nil here, so maybe we should just do the revert there?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.
This logic doesn't make sense to me. If the function returns false, then we don't want to revert the changes. Am I missing something here?
As a follow up, we don't know
nextLatestHeader
until after the for-loop (becauseevents
is added to bybuildCanonicalChain
). Having said this, I don't think that we can do the revert earlier unless me make a different refactor first.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.
You're right. For some reason, i thought
shouldRevertChanges
would return true instead of false. Thelen(events) == 0
check in the function is still dead code though.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.
No worries, this happens to me all the time. I'll check out the deadcode. If the event length is 0, then we really don't want to revert changes, so I want to be careful that this change wouldn't introduce problems if the function was re-used elsewhere.
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.
I think I'm going to leave this in for now. Let's address this in a refactor, which may entail completely eliminating this function.
My rationale is that removing the deadcode makes the function more context specific (you have to check
len(events) == 0
elsewhere for it to work properly). This is okay in this case because it's only called once, but I don't really like that since we are encapsulating logic in a function that should be reusable.