Skip to content

Commit

Permalink
Merge pull request #267 from tonkeeper/ignore-0000
Browse files Browse the repository at this point in the history
Dont track pending tx for 0:0000000....
  • Loading branch information
mr-tron authored Dec 5, 2023
2 parents 68cc1e3 + 866a235 commit 3f536ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/api/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 3f536ef

Please sign in to comment.