[NOD-337] In CheckTransactionSanity make max mass of transaction to be half of block max mass (#421)

* [NOD-337] In CheckTransactionSanity, made max mass of transaction to be half of block max mass.

* [NOD-337] Added a comment for MaxMassPerTx.

* [NOD-337] Fixed a couple of comments.
This commit is contained in:
stasatdaglabs 2019-09-24 14:27:04 +03:00 committed by Svarog
parent ece0fb83e8
commit e3aa8d65dc
2 changed files with 5 additions and 2 deletions

View File

@ -125,7 +125,7 @@ func CheckTransactionSanity(tx *util.Tx, subnetworkID *subnetworkid.SubnetworkID
// A transaction must not exceed the maximum allowed block mass when
// serialized.
serializedTxSize := msgTx.SerializeSize()
if serializedTxSize*massPerTxByte > wire.MaxMassPerBlock {
if serializedTxSize*massPerTxByte > wire.MaxMassPerTx {
str := fmt.Sprintf("serialized transaction is too big - got "+
"%d, max %d", serializedTxSize, wire.MaxMassPerBlock)
return ruleError(ErrTxMassTooHigh, str)

View File

@ -21,9 +21,12 @@ import (
// backing array multiple times.
const defaultTransactionAlloc = 2048
// MaxMassPerBlock is the maximum total transaction mass a block may contain.
// MaxMassPerBlock is the maximum total transaction mass a block may have.
const MaxMassPerBlock = 10000000
// MaxMassPerTx is the maximum total mass a transaction may have.
const MaxMassPerTx = MaxMassPerBlock / 2
// maxTxPerBlock is the maximum number of transactions that could
// possibly fit into a block.
const maxTxPerBlock = (MaxMassPerBlock / minTxPayload) + 1