From 866a2358c6b15ac6ae8cc427f4a44a68ad037e52 Mon Sep 17 00:00:00 2001 From: "aleksej.paschenko" Date: Tue, 5 Dec 2023 19:30:19 +0300 Subject: [PATCH] Dont track pending tx for 0:0000000000000000000000000000000000000000000000000000000000000000 --- pkg/api/event_handlers.go | 3 +++ pkg/api/handler.go | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/pkg/api/event_handlers.go b/pkg/api/event_handlers.go index ec82ae64..918acba8 100644 --- a/pkg/api/event_handlers.go +++ b/pkg/api/event_handlers.go @@ -589,6 +589,9 @@ func (h *Handler) addToMempool(ctx context.Context, bytesBoc []byte, shardAccoun h.mempoolEmulate.mu.Lock() defer h.mempoolEmulate.mu.Unlock() for account := range accounts { + if _, ok := h.mempoolEmulateIgnoreAccounts[account]; ok { + continue + } traces, _ := h.mempoolEmulate.accountsTraces.Get(account) traces = slices.Insert(traces, 0, hex.EncodeToString(hash)) h.mempoolEmulate.accountsTraces.Set(account, traces, cache.WithExpiration(time.Second*time.Duration(ttl))) diff --git a/pkg/api/handler.go b/pkg/api/handler.go index e4124870..39949cb7 100644 --- a/pkg/api/handler.go +++ b/pkg/api/handler.go @@ -50,6 +50,9 @@ type Handler struct { // ctxToDetails converts a request context to a details instance. ctxToDetails ctxToDetails + // mempoolEmulateIgnoreAccounts, we don't track pending transactions for this list of accounts. + mempoolEmulateIgnoreAccounts map[tongo.AccountID]struct{} + // mu protects "dns". mu sync.Mutex dns *dns.DNS // todo: update when blockchain config changes @@ -210,6 +213,9 @@ func NewHandler(logger *zap.Logger, opts ...Option) (*Handler, error) { traces: cache.NewLRUCache[string, *core.Trace](10000, "mempool_traces_cache"), accountsTraces: cache.NewLRUCache[tongo.AccountID, []string](10000, "accounts_traces_cache"), }, + mempoolEmulateIgnoreAccounts: map[tongo.AccountID]struct{}{ + tongo.MustParseAddress("0:0000000000000000000000000000000000000000000000000000000000000000").ID: {}, + }, tonConnect: tonConnect, }, nil }