-
Notifications
You must be signed in to change notification settings - Fork 501
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
ingest/ledgerbackend: Let filewatcher check for binary hash to detect captive core updates. #4050
Conversation
26619e6
to
3d94868
Compare
"github.com/stellar/go/support/log" | ||
) | ||
|
||
type hash []byte |
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.
nit: I don't think this type alias provides much benefit since we end up using bytes.Equal to compare hashes anyways
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.
Fair point. I slightly prefer to keep the type definition though, so I defined a Equals
method for type hash
that just calls byte.Equals
.
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.
We could've kept the old watcher, but I doubt anyone would miss it. LGTM 👍 Just one comment below ⬇️
ingest/ledgerbackend/file_watcher.go
Outdated
"github.com/stellar/go/support/log" | ||
) | ||
|
||
type hash []byte | ||
|
||
func (h *hash) Equals(other hash) bool { |
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.
what's the rationale for making the function have a pointer receiver?
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 wasn't thinking too much about it. I think defining it on the object itself makes a copy of it, which doesn't seem like a big deal either way. Do you have a reason to prefer one or the other?
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.
In https://github.com/golang/go/wiki/CodeReviewComments#receiver-type it states:
If the receiver is a slice and the method doesn't reslice or reallocate the slice, don't use a pointer to it.
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.
Sounds good to me. Updated.
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
Let
file_watcher
check for binary hash to detect captive core updates.Why
Horizon watches it's captive stellar-core binary timestamp to detect if a new version has been deployed. However, the binaries are timestamped with the package changelog, which is not dynamically updated during build.
Known limitations
The hash function currently takes < ~30ms to finish. The 10 second duration for
file_watcher
's loop should be sufficient.