feat: temporaily disable cache

This commit is contained in:
Mohamed Sohail 2024-06-10 15:24:13 +08:00
parent ed3d67b143
commit c4b5ef7a2d
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D
2 changed files with 25 additions and 27 deletions

View File

@ -11,8 +11,6 @@ import (
"syscall"
"time"
"github.com/grassrootseconomics/celo-indexer/internal/cache"
"github.com/grassrootseconomics/celo-indexer/internal/chain"
"github.com/grassrootseconomics/celo-indexer/internal/handler"
"github.com/grassrootseconomics/celo-indexer/internal/store"
"github.com/grassrootseconomics/celo-indexer/internal/sub"
@ -48,22 +46,22 @@ func main() {
var wg sync.WaitGroup
ctx, stop := notifyShutdown()
chain, err := chain.NewChainProvider(chain.ChainOpts{
RPCEndpoint: ko.MustString("chain.rpc_endpoint"),
ChainID: ko.MustInt64("chain.chainid"),
})
if err != nil {
lo.Error("chain provider bootstrap failed", "error", err)
os.Exit(1)
}
cache := cache.NewCache()
// chain, err := chain.NewChainProvider(chain.ChainOpts{
// RPCEndpoint: ko.MustString("chain.rpc_endpoint"),
// ChainID: ko.MustInt64("chain.chainid"),
// })
// if err != nil {
// lo.Error("chain provider bootstrap failed", "error", err)
// os.Exit(1)
// }
// cache := cache.NewCache()
lo.Info("starting cache bootstrap this may take a few minutes")
if err := chain.BootstrapCache(ko.MustStrings("bootstrap.ge_registries"), cache); err != nil {
lo.Error("cache bootstrap failed", "error", err)
os.Exit(1)
}
lo.Info("cache bootstrap completed successfully", "cache_size", cache.Size())
// lo.Info("starting cache bootstrap this may take a few minutes")
// if err := chain.BootstrapCache(ko.MustStrings("bootstrap.ge_registries"), cache); err != nil {
// lo.Error("cache bootstrap failed", "error", err)
// os.Exit(1)
// }
// lo.Info("cache bootstrap completed successfully", "cache_size", cache.Size())
store, err := store.NewPgStore(store.PgOpts{
Logg: lo,
@ -78,7 +76,7 @@ func main() {
handler := handler.NewHandler(handler.HandlerOpts{
Store: store,
Cache: cache,
// Cache: cache,
})
jetStreamSub, err := sub.NewJetStreamSub(sub.JetStreamOpts{

View File

@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"github.com/grassrootseconomics/celo-indexer/internal/cache"
"github.com/grassrootseconomics/celo-indexer/internal/store"
"github.com/grassrootseconomics/celo-tracker/pkg/event"
)
@ -12,19 +11,19 @@ import (
type (
HandlerOpts struct {
Store store.Store
Cache *cache.Cache
// Cache *cache.Cache
}
Handler struct {
store store.Store
cache *cache.Cache
// cache *cache.Cache
}
)
func NewHandler(o HandlerOpts) *Handler {
return &Handler{
store: o.Store,
cache: o.Cache,
// cache: o.Cache,
}
}
@ -37,12 +36,13 @@ func (h *Handler) Handle(ctx context.Context, msgSubject string, msgData []byte)
switch msgSubject {
case "TRACKER.TOKEN_TRANSFER":
from := chainEvent.Payload["from"].(string)
to := chainEvent.Payload["to"].(string)
// from := chainEvent.Payload["from"].(string)
// to := chainEvent.Payload["to"].(string)
if h.cache.Exists(from) || h.cache.Exists(to) {
// if h.cache.Exists(from) || h.cache.Exists(to) {
// return h.store.InsertTokenTransfer(ctx, chainEvent)
// }
return h.store.InsertTokenTransfer(ctx, chainEvent)
}
case "TRACKER.POOL_SWAP":
return h.store.InsertPoolSwap(ctx, chainEvent)
case "TRACKER.FAUCET_GIVE":