Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mxc_txpool block addresses #46

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions eth/mxc_api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,31 @@
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)

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 {

Check failure on line 146 in eth/mxc_api_backend.go

View workflow job for this annotation

GitHub Actions / test

S1011: should replace loop with `pendingTxs = append(pendingTxs, txs...)` (gosimple)
pendingTxs = append(pendingTxs, tx)
}

Expand Down
Loading