mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-20 13:56:45 +00:00

* fix mempool accessing, rewrite get_mempool_entries_by_addresses * fix counter, add verbose * fmt * addresses as string * Define error in case utxoEntry is missing. * fix error variable to string * stop tests from failing (see in code comment) * access both pools in the same state via parameters * get rid of todo message * fmt - very important! * perf: scriptpublickey in mempool, no txscript. * address reveiw * fmt fix * mixed up isorphan bool, pass tests now * do map preallocation in mempoolbyaddresses * no proallocation for orphanpool sending. Co-authored-by: Ori Newman <orinewman1@gmail.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package mempool
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/miningmanager/mempool/model"
|
|
"github.com/kaspanet/kaspad/infrastructure/logger"
|
|
)
|
|
|
|
func (mp *mempool) revalidateHighPriorityTransactions() ([]*externalapi.DomainTransaction, error) {
|
|
onEnd := logger.LogAndMeasureExecutionTime(log, "revalidateHighPriorityTransactions")
|
|
defer onEnd()
|
|
|
|
validTransactions := []*externalapi.DomainTransaction{}
|
|
for _, transaction := range mp.transactionsPool.highPriorityTransactions {
|
|
isValid, err := mp.revalidateTransaction(transaction)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if !isValid {
|
|
continue
|
|
}
|
|
|
|
validTransactions = append(validTransactions, transaction.Transaction().Clone())
|
|
}
|
|
|
|
return validTransactions, nil
|
|
}
|
|
|
|
func (mp *mempool) revalidateTransaction(transaction *model.MempoolTransaction) (isValid bool, err error) {
|
|
clearInputs(transaction)
|
|
|
|
_, missingParents, err := mp.fillInputsAndGetMissingParents(transaction.Transaction())
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if len(missingParents) > 0 {
|
|
log.Debugf("Removing transaction %s, it failed revalidation", transaction.TransactionID())
|
|
err := mp.removeTransaction(transaction.TransactionID(), true)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return false, nil
|
|
}
|
|
|
|
return true, nil
|
|
}
|
|
|
|
func clearInputs(transaction *model.MempoolTransaction) {
|
|
for _, input := range transaction.Transaction().Inputs {
|
|
input.UTXOEntry = nil
|
|
}
|
|
}
|