Skip to content

Commit 5db9c31

Browse files
authored
Revert "async commit + wh (#263)"
This reverts commit 272d9c6.
1 parent 7e62d5e commit 5db9c31

File tree

9 files changed

+60
-799
lines changed

9 files changed

+60
-799
lines changed

configs/config.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"os"
7-
"strconv"
87
"strings"
98

109
"github.com/rs/zerolog/log"
@@ -86,13 +85,6 @@ type ClickhouseConfig struct {
8685
ChainBasedConfig map[string]TableOverrideConfig `mapstructure:"chainBasedConfig"`
8786
EnableParallelViewProcessing bool `mapstructure:"enableParallelViewProcessing"`
8887
MaxQueryTime int `mapstructure:"maxQueryTime"`
89-
90-
// Readonly configuration for API endpoints
91-
ReadonlyHost string `mapstructure:"readonlyHost"`
92-
ReadonlyPort int `mapstructure:"readonlyPort"`
93-
ReadonlyUsername string `mapstructure:"readonlyUsername"`
94-
ReadonlyPassword string `mapstructure:"readonlyPassword"`
95-
ReadonlyDatabase string `mapstructure:"readonlyDatabase"`
9688
}
9789

9890
type PostgresConfig struct {
@@ -290,35 +282,5 @@ func setCustomJSONConfigs() error {
290282
Cfg.Storage.Main.Clickhouse.ChainBasedConfig = orchestratorChainConfig
291283
}
292284
}
293-
294-
// Load readonly ClickHouse configuration from environment variables
295-
if readonlyHost := os.Getenv("CLICKHOUSE_HOST_READONLY"); readonlyHost != "" {
296-
if Cfg.Storage.Main.Clickhouse != nil {
297-
Cfg.Storage.Main.Clickhouse.ReadonlyHost = readonlyHost
298-
}
299-
}
300-
if readonlyPort := os.Getenv("CLICKHOUSE_PORT_READONLY"); readonlyPort != "" {
301-
if port, err := strconv.Atoi(readonlyPort); err == nil {
302-
if Cfg.Storage.Main.Clickhouse != nil {
303-
Cfg.Storage.Main.Clickhouse.ReadonlyPort = port
304-
}
305-
}
306-
}
307-
if readonlyUsername := os.Getenv("CLICKHOUSE_USER_READONLY"); readonlyUsername != "" {
308-
if Cfg.Storage.Main.Clickhouse != nil {
309-
Cfg.Storage.Main.Clickhouse.ReadonlyUsername = readonlyUsername
310-
}
311-
}
312-
if readonlyPassword := os.Getenv("CLICKHOUSE_PASSWORD_READONLY"); readonlyPassword != "" {
313-
if Cfg.Storage.Main.Clickhouse != nil {
314-
Cfg.Storage.Main.Clickhouse.ReadonlyPassword = readonlyPassword
315-
}
316-
}
317-
if readonlyDatabase := os.Getenv("CLICKHOUSE_DATABASE_READONLY"); readonlyDatabase != "" {
318-
if Cfg.Storage.Main.Clickhouse != nil {
319-
Cfg.Storage.Main.Clickhouse.ReadonlyDatabase = readonlyDatabase
320-
}
321-
}
322-
323285
return nil
324286
}

configs/config_readonly_example.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

docs/README_READONLY_CLICKHOUSE.md

Lines changed: 0 additions & 235 deletions
This file was deleted.

insight

100644100755
49.2 MB
Binary file not shown.

internal/handlers/logs_handlers.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package handlers
22

33
import (
44
"net/http"
5+
"sync"
56

67
"github.com/ethereum/go-ethereum/accounts/abi"
78
"github.com/gin-gonic/gin"
@@ -12,6 +13,13 @@ import (
1213
"github.com/thirdweb-dev/indexer/internal/storage"
1314
)
1415

16+
// package-level variables
17+
var (
18+
mainStorage storage.IMainStorage
19+
storageOnce sync.Once
20+
storageErr error
21+
)
22+
1523
// @Summary Get all logs
1624
// @Description Retrieve all logs across all contracts
1725
// @Tags events
@@ -213,6 +221,18 @@ func decodeLogsIfNeeded(chainId string, logs []common.Log, eventABI *abi.Event,
213221
return nil
214222
}
215223

224+
func getMainStorage() (storage.IMainStorage, error) {
225+
storageOnce.Do(func() {
226+
var err error
227+
mainStorage, err = storage.NewConnector[storage.IMainStorage](&config.Cfg.Storage.Main)
228+
if err != nil {
229+
storageErr = err
230+
log.Error().Err(err).Msg("Error creating storage connector")
231+
}
232+
})
233+
return mainStorage, storageErr
234+
}
235+
216236
func sendJSONResponse(c *gin.Context, response interface{}) {
217237
c.JSON(http.StatusOK, response)
218238
}

0 commit comments

Comments
 (0)