[NOD-1486] Make coinbase mass and size 0 (#970)

This commit is contained in:
Ori Newman 2020-10-27 08:14:02 -07:00 committed by GitHub
parent aeb4b96560
commit f62183473c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/kaspanet/kaspad/domain/consensus/ruleerrors"
"github.com/kaspanet/kaspad/domain/consensus/utils/estimatedsize"
"github.com/kaspanet/kaspad/domain/consensus/utils/transactionhelper"
"github.com/kaspanet/kaspad/domain/consensus/utils/txscript"
"github.com/pkg/errors"
)
@ -34,6 +35,10 @@ func (v *transactionValidator) transactionMassStandalonePart(tx *externalapi.Dom
}
func (v *transactionValidator) transactionMass(tx *externalapi.DomainTransaction) (uint64, error) {
if transactionhelper.IsCoinBase(tx) {
return 0, nil
}
standaloneMass := v.transactionMassStandalonePart(tx)
sigOpsCount := uint64(0)
for _, input := range tx.Inputs {

View File

@ -2,6 +2,7 @@ package estimatedsize
import (
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/kaspanet/kaspad/domain/consensus/utils/transactionhelper"
)
// TransactionEstimatedSerializedSize is the estimated size of a transaction in some
@ -9,6 +10,9 @@ import (
// it's only used as the size component in the transaction mass and block size limit
// calculation.
func TransactionEstimatedSerializedSize(tx *externalapi.DomainTransaction) uint64 {
if transactionhelper.IsCoinBase(tx) {
return 0
}
size := uint64(0)
size += 8 // number of inputs (uint64)