Fix getLogs query (avoid repeated execution, separate tx, and improve performance) (#250)

* Avoid repeated queries in getLogs.

* Rewrite query for speed and simplicity.

* Make default limit 500
This commit is contained in:
2023-06-16 11:49:56 -05:00
committed by GitHub
parent 60b2f5f4f3
commit 39f8b6ec79
7 changed files with 107 additions and 76 deletions
+9
View File
@@ -56,6 +56,7 @@ const (
ETH_FORWARD_ETH_CALLS = "ETH_FORWARD_ETH_CALLS"
ETH_FORWARD_GET_STORAGE_AT = "ETH_FORWARD_GET_STORAGE_AT"
ETH_PROXY_ON_ERROR = "ETH_PROXY_ON_ERROR"
ETH_GETLOGS_BLOCK_LIMIT = "ETH_GETLOGS_BLOCK_LIMIT"
VALIDATOR_ENABLED = "VALIDATOR_ENABLED"
VALIDATOR_EVERY_NTH_BLOCK = "VALIDATOR_EVERY_NTH_BLOCK"
@@ -107,6 +108,7 @@ type Config struct {
ForwardEthCalls bool
ForwardGetStorageAt bool
ProxyOnError bool
GetLogsBlockLimit int64
NodeNetworkID string
// Cache configuration.
@@ -134,6 +136,7 @@ func NewConfig() (*Config, error) {
viper.BindEnv("ethereum.forwardEthCalls", ETH_FORWARD_ETH_CALLS)
viper.BindEnv("ethereum.forwardGetStorageAt", ETH_FORWARD_GET_STORAGE_AT)
viper.BindEnv("ethereum.proxyOnError", ETH_PROXY_ON_ERROR)
viper.BindEnv("ethereum.getLogsBlockLimit", ETH_GETLOGS_BLOCK_LIMIT)
viper.BindEnv("log.file", "LOG_FILE")
viper.BindEnv("log.level", "LOG_LEVEL")
@@ -152,6 +155,12 @@ func NewConfig() (*Config, error) {
c.ProxyOnError = viper.GetBool("ethereum.proxyOnError")
c.EthHttpEndpoint = ethHTTPEndpoint
if viper.IsSet("ethereum.getLogsBlockLimit") {
c.GetLogsBlockLimit = viper.GetInt64("ethereum.getLogsBlockLimit")
} else {
c.GetLogsBlockLimit = 500
}
// websocket server
wsEnabled := viper.GetBool("server.ws")
if wsEnabled {