コード例 #1
0
        /// <inheritdoc/>
        protected override bool TestPackage(TxMempoolEntry entry, long packageSize, long packageSigOpsCost)
        {
            if (this.futureDriftRule == null)
            {
                this.futureDriftRule = this.ConsensusManager.ConsensusRules.GetRule <PosFutureDriftRule>();
            }

            long adjustedTime    = this.DateTimeProvider.GetAdjustedTimeAsUnixTimestamp();
            long latestValidTime = adjustedTime + this.futureDriftRule.GetFutureDrift(adjustedTime);

            // We can include txes with timestamp greater than header's timestamp and those txes are invalid to have in block.
            // However this is needed in order to avoid recreation of block template on every attempt to find kernel.
            // When kernel is found txes with timestamp greater than header's timestamp are removed.
            if (entry.Transaction is IPosTransactionWithTime posTrx)
            {
                if (posTrx.Time > latestValidTime)
                {
                    this.logger.LogDebug("Transaction '{0}' has timestamp of {1} but latest valid tx time that can be mined is {2}.", entry.TransactionHash, posTrx.Time, latestValidTime);
                    this.logger.LogTrace("(-)[TOO_EARLY_TO_MINE_TX]:false");
                    return(false);
                }
            }

            return(base.TestPackage(entry, packageSize, packageSigOpsCost));
        }
コード例 #2
0
        /// <inheritdoc/>
        protected override bool TestPackage(TxMempoolEntry entry, long packageSize, long packageSigOpsCost)
        {
            if (this.futureDriftRule == null)
            {
                this.futureDriftRule = this.ConsensusManager.ConsensusRules.GetRule <PosFutureDriftRule>();
            }

            long adjustedTime = this.DateTimeProvider.GetAdjustedTimeAsUnixTimestamp();

            if (entry.Transaction.Time > adjustedTime + this.futureDriftRule.GetFutureDrift(adjustedTime))
            {
                return(false);
            }

            return(base.TestPackage(entry, packageSize, packageSigOpsCost));
        }