mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-02-24 04:13:16 +00:00
Compare commits
2 Commits
send-patch
...
anti-spam-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74d5181bea | ||
|
|
0bbb307f84 |
@@ -138,6 +138,11 @@ func (tp *transactionsPool) allReadyTransactions() []*externalapi.DomainTransact
|
||||
if len(mempoolTransaction.ParentTransactionsInPool()) == 0 {
|
||||
result = append(result, mempoolTransaction.Transaction().Clone()) //this pointer leaves the mempool, and gets its utxo set to nil, hence we clone.
|
||||
}
|
||||
|
||||
if numOutsLessThanOneKas, isSpamming := isTXSpamming(mempoolTransaction.Transaction()); isSpamming {
|
||||
log.Warnf("Filtered from allReadyTransactions transaction %s with %d outputs with less than 1 KAS", mempoolTransaction.TransactionID(), numOutsLessThanOneKas)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@@ -2,6 +2,7 @@ package mempool
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
|
||||
|
||||
"github.com/kaspanet/kaspad/infrastructure/logger"
|
||||
|
||||
@@ -16,6 +17,11 @@ func (mp *mempool) validateAndInsertTransaction(transaction *externalapi.DomainT
|
||||
fmt.Sprintf("validateAndInsertTransaction %s", consensushashing.TransactionID(transaction)))
|
||||
defer onEnd()
|
||||
|
||||
if numOutsLessThanOneKas, isSpamming := isTXSpamming(transaction); isSpamming {
|
||||
log.Warnf("Rejected from mempool transaction %s with %d outputs with less than 1 KAS", consensushashing.TransactionID(transaction), numOutsLessThanOneKas)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Populate mass in the beginning, it will be used in multiple places throughout the validation and insertion.
|
||||
mp.consensusReference.Consensus().PopulateMass(transaction)
|
||||
|
||||
@@ -63,3 +69,14 @@ func (mp *mempool) validateAndInsertTransaction(transaction *externalapi.DomainT
|
||||
|
||||
return acceptedTransactions, nil
|
||||
}
|
||||
|
||||
func isTXSpamming(transaction *externalapi.DomainTransaction) (int, bool) {
|
||||
numOutsLessThanOneKas := 0
|
||||
for _, output := range transaction.Outputs {
|
||||
if output.Value < constants.SompiPerKaspa {
|
||||
numOutsLessThanOneKas += 1
|
||||
}
|
||||
}
|
||||
|
||||
return numOutsLessThanOneKas, numOutsLessThanOneKas > len(transaction.Inputs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user