-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: add support for multiple eth rpc endpoints #199
Conversation
cmd/peggo/flags.go
Outdated
} | ||
log.Printf("%d of the provided Ethereum rpc endpoints are currently working", working) | ||
if connectionErrors > len(endpoints) { | ||
log.Println("too many connection errors, please double check your endpoints and try again") |
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 a nil return or similar be added to break out of the for loop after logging this message?
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 added one in the latest commit.
cmd/peggo/flags.go
Outdated
if err != nil { | ||
connectionErrors += 1 | ||
log.Println("failed to dial rpc node: %w", err) | ||
continue |
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.
continue |
Since else
is below
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.
good catch. fixed in the latest commit.
cmd/peggo/flags.go
Outdated
|
||
func ethClientConnect(rawEndpoints string) *ethclient.Client { | ||
connectionErrors := 0 | ||
return func() *ethclient.Client { |
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.
If I'm reading this right, the return func() *ethclient.Client { }()
structure wrapped around the for
loop can be removed without ill effects.
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.
Correct. I originally wanted to put the anonymous functions in goroutine. Then I forgot to after shifting some code around. In the latest commit I removed the anonymous function within the connect function itself, and instead wrapped the connect function in goroutine when called.
- Misc. linting fixes - Wrap ethClientConnect and ethRpcClientConnect in goroutine
Thanks for the contribution @jim380! But after further evaluation, I think this problem is actually a bit more complex than we thought and we're currently considering an approach at the nginx proxy level. |
Resolves Issue #196