-
Notifications
You must be signed in to change notification settings - Fork 176
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
db: return Miniheader with zero values rather than nil from FindLatestMiniheader when no headers are found #1809
Conversation
484e05c
to
64cf87d
Compare
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.
Looks like there are multiple places in block_watcher.go
that depend on FindLatestMiniHeader() returning a nil header when there are no headers in the DB. Here is one and here is another. There may be more. Currently, I think returning the zero value for a header in FindLatestMiniHeader() might cause breakage in those areas.
Could be worth weighing continuing to return a nil header and just adding a check for that in the code path that was causing a nil pointer error.
64cf87d
to
9e99a42
Compare
Reverted to old behaviour and added a nil check. Also added a quick one character fix for #1780. Tested on rinkeby and checked if there were other cases we should add a nil check but didn't see any immeadiatly. Will double-check. |
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.
LGTM after squashing
489b81a
to
6b38c3d
Compare
b492bdd
to
7cc6a6f
Compare
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.
One comment on changelog, but LGTM after fixing.
7cc6a6f
to
8ab68ee
Compare
This one okay to merge ? |
Yep and already approved. |
What does this pull request do? Explain your changes. (required)
Instead of returning
nil
fromdb.FindLatestMiniHeader
when no entries are found in the database we return a zero-value to avoid unexpected behaviour whereby no error and no value is returned.This behaviour is similar to the underlying
ethClient.HeaderByNumber
implementation.note
Consider changing
blockWatch.Miniheader.Number
to anint64
orbig.Int
instead of a pointer reference*big.Int
to avoid explicit initialisation of this field.Specific updates (required)
blocksElapsed
to be<=0
to avoid verbose logging when no blocks have elapsed.How did you test each of these updates (required)
Ran unit tests
Does this pull request close any open issues?
Fixes #1803
Fixes #1780
Checklist:
make
runs successfully./test.sh
pass