-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
channeldb: inject clock into database #3797
channeldb: inject clock into database #3797
Conversation
channeldb/db.go
Outdated
@@ -142,7 +142,9 @@ type DB struct { | |||
|
|||
// Open opens an existing channeldb. Any necessary schemas migrations due to | |||
// updates will take place as necessary. | |||
func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) { | |||
func Open(dbPath string, now func() time.Time, modifiers ...OptionModifier) ( |
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.
why not set time.Now
as the default in DefaultOptions()
, then add a functional modifier? much smaller diff
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.
Great suggestion, done
Just saw this. Now that we have clock.Clock you might as well use that instead of the now closure. |
d484505
to
9b9721a
Compare
Use our standard clock mock for database time queries.
9b9721a
to
b600ecd
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.
LGTM 🕥
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.
much cleaner, nice fix LGTM 🎸
This PR fixes a leftover of the mpp invoice registry pr #3415. There we took a shortcut to expose
Now
as a public field on the database in order to unblock the stack of dependent prs. This is now converted to a properclock.Clock
dependency.