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 {
|
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.
|
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
|
return result
|
||||||
|
@ -17,15 +17,8 @@ func (mp *mempool) validateAndInsertTransaction(transaction *externalapi.DomainT
|
|||||||
fmt.Sprintf("validateAndInsertTransaction %s", consensushashing.TransactionID(transaction)))
|
fmt.Sprintf("validateAndInsertTransaction %s", consensushashing.TransactionID(transaction)))
|
||||||
defer onEnd()
|
defer onEnd()
|
||||||
|
|
||||||
numOutsLessThanOneKas := 0
|
if numOutsLessThanOneKas, isSpamming := isTXSpamming(transaction); isSpamming {
|
||||||
for _, output := range transaction.Outputs {
|
log.Warnf("Rejected from mempool transaction %s with %d outputs with less than 1 KAS", consensushashing.TransactionID(transaction), numOutsLessThanOneKas)
|
||||||
if output.Value < constants.SompiPerKaspa {
|
|
||||||
numOutsLessThanOneKas += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if numOutsLessThanOneKas > len(transaction.Inputs) {
|
|
||||||
log.Warnf("Rejected transaction with %d outputs with less than 1 KAS")
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,3 +69,14 @@ func (mp *mempool) validateAndInsertTransaction(transaction *externalapi.DomainT
|
|||||||
|
|
||||||
return acceptedTransactions, nil
|
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