mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-21 06:16:45 +00:00

* Update constants * Add to transaction SigOpCount * Update mass calculation, and move it from InContext to InIsolation * Update block validation accordingly * Add SigOpCount validation during TransactionInContext * Remove checking of mass vs maxMassAcceptedByBlock from consensusStateManager * Update mining manager with latest changes * Add SigOpCount to MsgTx.Copy() * Fix initTestTransactionAcceptanceDataForClone * Fix all tests in transaction_equal_clone_test.go * Fix TestBlockMass * Fix tests in transactionvalidator package * Add SigOpCount to sighash * Fix TestPruningDepth * Fix problems in libkaspawalelt * Fix integration tests * Fix CalculateSignatureHash tests * Remove remaining places talking about block size * Add sanity check to checkBlockMass to make sure all transactions have their mass filled * always add own sigOpCount to sigHash * Update protowire/rpc.md * Start working on removing any remaining reference to block/tx size * Update rpc transaction verbose data to include mass rather then size * Convert verboseData and block size check to mass * Remove remaining usages of tx size in mempool * Move transactionEstimatedSerializedSize to transactionvalidator * Add PopulateMass to fakeRelayInvsContext * Move PopulateMass to beggining of ValidateAndInsertTransaction + fix in it * Assign mass a new number for backward-compatibility
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
package mempool
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
|
|
)
|
|
|
|
func (mp *mempool) validateTransactionPreUTXOEntry(transaction *externalapi.DomainTransaction) error {
|
|
err := mp.validateTransactionInIsolation(transaction)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := mp.mempoolUTXOSet.checkDoubleSpends(transaction); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (mp *mempool) validateTransactionInIsolation(transaction *externalapi.DomainTransaction) error {
|
|
transactionID := consensushashing.TransactionID(transaction)
|
|
if _, ok := mp.transactionsPool.allTransactions[*transactionID]; ok {
|
|
return transactionRuleError(RejectDuplicate,
|
|
fmt.Sprintf("transaction %s is already in the mempool", transactionID))
|
|
}
|
|
|
|
if !mp.config.AcceptNonStandard {
|
|
if err := mp.checkTransactionStandardInIsolation(transaction); err != nil {
|
|
// Attempt to extract a reject code from the error so
|
|
// it can be retained. When not possible, fall back to
|
|
// a non standard error.
|
|
rejectCode, found := extractRejectCode(err)
|
|
if !found {
|
|
rejectCode = RejectNonstandard
|
|
}
|
|
str := fmt.Sprintf("transaction %s is not standard: %s", transactionID, err)
|
|
return transactionRuleError(rejectCode, str)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (mp *mempool) validateTransactionInContext(transaction *externalapi.DomainTransaction) error {
|
|
if !mp.config.AcceptNonStandard {
|
|
err := mp.checkTransactionStandardInContext(transaction)
|
|
if err != nil {
|
|
// Attempt to extract a reject code from the error so
|
|
// it can be retained. When not possible, fall back to
|
|
// a non standard error.
|
|
rejectCode, found := extractRejectCode(err)
|
|
if !found {
|
|
rejectCode = RejectNonstandard
|
|
}
|
|
str := fmt.Sprintf("transaction inputs %s are not standard: %s",
|
|
consensushashing.TransactionID(transaction), err)
|
|
return transactionRuleError(rejectCode, str)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|