-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
golangci-lint: add unconvert #11757
golangci-lint: add unconvert #11757
Conversation
I see that you haven't updated any README files. Would it make sense to do so? |
58fe6f7
to
87f2b46
Compare
87f2b46
to
868ab29
Compare
SonarQube Quality Gate |
@@ -236,7 +236,7 @@ func (f *FwdMgr) runLoop() { | |||
defer f.wg.Done() | |||
tick := time.After(0) | |||
|
|||
for ; ; tick = time.After(utils.WithJitter(time.Duration(time.Minute))) { | |||
for ; ; tick = time.After(utils.WithJitter(time.Minute)) { |
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.
Unrelated to the scope of this PR - is there a more idiomatic way to write this?
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 does seem odd. Moving the assignment to the body isn't straightforward though (extra bool might be most elegant?).
I might actually prefer moving the init here:
for ; ; tick = time.After(utils.WithJitter(time.Minute)) { | |
for tick := time.After(0); ; tick = time.After(utils.WithJitter(time.Minute)) { |
Or, since this is a common pattern that we use instead of a plain time.Ticker
, we could just make a custom type of Ticker which sends the first tick without delay. The jitter can become an implementation detail this way too:
for ; ; tick = time.After(utils.WithJitter(time.Minute)) { | |
ticker := services.NewTicker(time.Minute) | |
defer ticker.Stop() | |
for { |
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.
Here is a quick hack: smartcontractkit/chainlink-common#311
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.
Nice!
c.lock.RLock() | ||
defer c.lock.RUnlock() | ||
|
||
i := int64(block) % int64(c.cap) | ||
i := int64(block) % c.cap | ||
b := c.buffer[i] | ||
if b.block != block { | ||
return ocr2keepers.TransmitEvent{}, false |
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 This feels more readable to me
func (c *transmitEventCache) get(block int64, logID string) (ocr2keepers.TransmitEvent, bool) {
c.lock.RLock()
defer c.lock.RUnlock()
i := block % c.cap // no longer has an int64 cast on block
b := c.buffer[i]
if int64(b.block) != block { //has an int64 cast on b.block
return ocr2keepers.TransmitEvent{}, false
}
if len(b.records) == 0 {
return ocr2keepers.TransmitEvent{}, false
}
e, ok := b.records[logID]
return e, ok
}
I'm not sure on the tradeoff with this pattern:
type BlockNumber uint64
What's the readability/usability gain relative to all the casting when we need to perform an int64 operation?
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 don't know this code, but that makes sense to me.
@@ -74,7 +74,7 @@ var _ Task = (*BridgeTask)(nil) | |||
|
|||
var zeroURL = new(url.URL) | |||
|
|||
const stalenessCap = time.Duration(30 * time.Minute) |
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.
Should this have a comment explaining where it comes from or be wired through config?
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 does seem arbitrary. Introduced here: #7964
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.
🚀
Had some questions outside the scope of this PR
No description provided.