Skip to content
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

Closed
wants to merge 2 commits into from
Closed

feat: add support for multiple eth rpc endpoints #199

wants to merge 2 commits into from

Conversation

jim380
Copy link

@jim380 jim380 commented Feb 20, 2022

Resolves Issue #196

}
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")
Copy link
Member

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?

Copy link
Author

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.

if err != nil {
connectionErrors += 1
log.Println("failed to dial rpc node: %w", err)
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
continue

Since else is below

Copy link
Author

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.


func ethClientConnect(rawEndpoints string) *ethclient.Client {
connectionErrors := 0
return func() *ethclient.Client {
Copy link
Member

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.

Copy link
Author

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
@alexanderbez
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants