Skip to content

Commit 722b0ec

Browse files
committed
enable block receipts method
1 parent b37f7f7 commit 722b0ec

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

configs/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func LoadConfig(cfgFile string) error {
9494
panic(err)
9595
}
9696

97+
// Set default values for viper-managed configs
98+
viper.SetDefault("rpc.blockReceipts.enabled", true)
99+
97100
if cfgFile != "" {
98101
viper.SetConfigFile(cfgFile)
99102
if err := viper.ReadInConfig(); err != nil {

internal/rpc/rpc.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,18 @@ func (rpc *Client) checkGetBlockByNumberSupport() error {
181181
}
182182

183183
func (rpc *Client) checkGetBlockReceiptsSupport() error {
184-
if config.Cfg.RPC.BlockReceipts.Enabled {
185-
var getBlockReceiptsResult interface{}
186-
receiptsErr := rpc.RPCClient.Call(&getBlockReceiptsResult, "eth_getBlockReceipts", "latest")
187-
if receiptsErr != nil {
188-
log.Warn().Err(receiptsErr).Msg("eth_getBlockReceipts method not supported")
189-
return fmt.Errorf("eth_getBlockReceipts method not supported: %v", receiptsErr)
190-
} else {
191-
rpc.supportsBlockReceipts = true
192-
log.Debug().Msg("eth_getBlockReceipts method supported")
193-
}
194-
} else {
184+
// Always probe to see if the method is supported
185+
var getBlockReceiptsResult interface{}
186+
receiptsErr := rpc.RPCClient.Call(&getBlockReceiptsResult, "eth_getBlockReceipts", "latest")
187+
188+
if receiptsErr != nil {
189+
// Method not supported by RPC endpoint
195190
rpc.supportsBlockReceipts = false
196-
log.Debug().Msg("eth_getBlockReceipts method disabled")
191+
log.Warn().Err(receiptsErr).Msg("eth_getBlockReceipts method not supported by RPC endpoint")
192+
} else {
193+
// Method supported and enabled
194+
rpc.supportsBlockReceipts = true
195+
log.Info().Msg("eth_getBlockReceipts method enabled")
197196
}
198197
return nil
199198
}

0 commit comments

Comments
 (0)