From 1221351860c1668e3c3b243c0e177506d52fda6e Mon Sep 17 00:00:00 2001 From: luanxu-mxc Date: Sat, 19 Aug 2023 19:17:43 +0800 Subject: [PATCH] feat: mxc_txpool block addresses --- eth/mxc_api_backend.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/eth/mxc_api_backend.go b/eth/mxc_api_backend.go index 4163b25b76ab..86602adf9b4e 100644 --- a/eth/mxc_api_backend.go +++ b/eth/mxc_api_backend.go @@ -119,12 +119,12 @@ func filterBlockedTxs(pendings map[common.Address]types.Transactions, blockedAdd if len(blockedAddresses) == 0 { return pendings } - var localsAddresses []common.Address + var ignoreAddresses []common.Address for _, account := range blockedAddresses { if trimmed := strings.TrimSpace(account); !common.IsHexAddress(trimmed) { log.Warn(fmt.Sprintf("Invalid address: %s", trimmed)) } else { - localsAddresses = append(localsAddresses, common.HexToAddress(account)) + ignoreAddresses = append(ignoreAddresses, common.HexToAddress(account)) } } executableTxs := make(map[common.Address]types.Transactions) @@ -132,12 +132,17 @@ func filterBlockedTxs(pendings map[common.Address]types.Transactions, blockedAdd for addr, txs := range pendings { pendingTxs := make(types.Transactions, 0) - for _, blockedAddress := range localsAddresses { + blocked := false + for _, blockedAddress := range ignoreAddresses { if addr == blockedAddress { log.Debug(fmt.Sprintf("Ignore blocked address: %s", addr.Hex())) + blocked = true break } } + if blocked { + continue + } for _, tx := range txs { pendingTxs = append(pendingTxs, tx) }