TrueBlocks / trueblocks-core

The main repository for the TrueBlocks system
https://trueblocks.io
GNU General Public License v3.0
1.04k stars 194 forks source link

Check for valid rpc provider during `func init` #3791

Open tjayrush opened 2 weeks ago

tjayrush commented 2 weeks ago

There's always been confusion in the code about where the first call to the RPC provider happens. This causes errors because most regular users don't edit the config file to point to a valid RPC endpoint (which is set to http://localhost:8545 by default). Instead of a meaningful message, they get a very odd message complaining about the Unchained Index not existing.

There are multiple attempts in various places to try to fix this, but I don't feel that it's ever really been fixed.

Here's one such attempt that didn't work for some reason: https://github.com/TrueBlocks/trueblocks-core/blob/master/src/apps/chifra/internal/globals/validate.go#L31.

Here's the current best version of solving the problem: https://github.com/TrueBlocks/trueblocks-core/blob/master/src/apps/chifra/pkg/config/config.go#L242