mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
add more check
This commit is contained in:
parent
0bbb307f84
commit
74d5181bea
@ -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
|
||||
|
@ -17,15 +17,8 @@ func (mp *mempool) validateAndInsertTransaction(transaction *externalapi.DomainT
|
||||
fmt.Sprintf("validateAndInsertTransaction %s", consensushashing.TransactionID(transaction)))
|
||||
defer onEnd()
|
||||
|
||||
numOutsLessThanOneKas := 0
|
||||
for _, output := range transaction.Outputs {
|
||||
if output.Value < constants.SompiPerKaspa {
|
||||
numOutsLessThanOneKas += 1
|
||||
}
|
||||
}
|
||||
|
||||
if numOutsLessThanOneKas > len(transaction.Inputs) {
|
||||
log.Warnf("Rejected transaction with %d outputs with less than 1 KAS")
|
||||
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
|
||||
}
|
||||
|
||||
@ -76,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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user