Beispiel #1
0
        /// <summary>
        /// Constructs a memory pool orphan manager object.
        /// </summary>
        /// <param name="mempoolLock">A lock for managing asynchronous access to memory pool.</param>
        /// <param name="memPool">Transaction memory pool for managing transactions in the memory pool.</param>
        /// <param name="chain">Chain of block headers.</param>
        /// <param name="signals">Node notifications available to subscribe to.</param>
        /// <param name="validator">Memory pool validator for validating transactions.</param>
        /// <param name="consensusValidator">Proof of work consensus validator used for validating orphan transactions.</param>
        /// <param name="coinView">Coin view of the memory pool.</param>
        /// <param name="dateTimeProvider">Date and time information provider.</param>
        /// <param name="mempoolSettings">Settings from the memory pool.</param>
        /// <param name="loggerFactory">Factory for creating instance logger for this object.</param>
        public MempoolOrphans(
            MempoolAsyncLock mempoolLock,
            TxMempool memPool,
            ConcurrentChain chain,
            Signals.Signals signals,
            IMempoolValidator validator,
            PowConsensusValidator consensusValidator,
            CoinView coinView,
            IDateTimeProvider dateTimeProvider,
            MempoolSettings mempoolSettings,
            ILoggerFactory loggerFactory)
        {
            this.MempoolLock        = mempoolLock;
            this.memPool            = memPool;
            this.chain              = chain;
            this.signals            = signals;
            this.consensusValidator = consensusValidator;
            this.coinView           = coinView;
            this.dateTimeProvider   = dateTimeProvider;
            this.mempoolSettings    = mempoolSettings;
            this.Validator          = validator;

            this.mapOrphanTransactions       = new Dictionary <uint256, OrphanTx>();
            this.mapOrphanTransactionsByPrev = new Dictionary <OutPoint, List <OrphanTx> >(); // OutPoint already correctly implements equality compare
            this.recentRejects             = new Dictionary <uint256, uint256>();
            this.hashRecentRejectsChainTip = uint256.Zero;
            this.mempoolLogger             = loggerFactory.CreateLogger(this.GetType().FullName);
        }
Beispiel #2
0
        /// <inheritdoc />
        public MemPoolSaveResult Save(TxMempool memPool, string fileName = null)
        {
            fileName = fileName ?? DefaultFilename;
            IEnumerable <MempoolPersistenceEntry> toSave = memPool.MapTx.Values.ToArray().Select(tx => MempoolPersistenceEntry.FromTxMempoolEntry(tx));

            return(this.Save(toSave, fileName));
        }
 /// <summary>
 /// Constructs a memory pool coin view.
 /// </summary>
 /// <param name="inner">The backing coin view.</param>
 /// <param name="memPool">Transaction memory pool for managing transactions in the memory pool.</param>
 /// <param name="mempoolLock">A lock for managing asynchronous access to memory pool.</param>
 /// <param name="mempoolValidator">Memory pool validator for validating transactions.</param>
 public MempoolCoinView(CoinView inner, TxMempool memPool, AsyncLock mempoolLock, IMempoolValidator mempoolValidator)
 {
     this.Inner            = inner;
     this.memPool          = memPool;
     this.mempoolLock      = mempoolLock;
     this.mempoolValidator = mempoolValidator;
     this.Set = new UnspentOutputSet();
 }
 /// <summary>
 /// Constructs an instance of a memory pool manager object.
 /// </summary>
 /// <param name="mempoolLock">A lock for managing asynchronous access to memory pool.</param>
 /// <param name="memPool">Transaction memory pool for managing transactions in the memory pool.</param>
 /// <param name="validator">Memory pool validator for validating transactions.</param>
 /// <param name="orphans">Memory pool orphans for managing orphan transactions.</param>
 /// <param name="dateTimeProvider">Date and time information provider.</param>
 /// <param name="nodeArgs">Settings from the node.</param>
 /// <param name="mempoolPersistence">Memory pool persistence methods for loading and saving from storage.</param>
 /// <param name="loggerFactory">Logger factory for creating instance logger.</param>
 public MempoolManager(
     MempoolAsyncLock mempoolLock,
     TxMempool memPool,
     IMempoolValidator validator,
     MempoolOrphans orphans,
     IDateTimeProvider dateTimeProvider,
     NodeSettings nodeArgs,
     IMempoolPersistence mempoolPersistence,
     ILoggerFactory loggerFactory)
 {
     this.MempoolLock        = mempoolLock;
     this.memPool            = memPool;
     this.DateTimeProvider   = dateTimeProvider;
     this.NodeArgs           = nodeArgs;
     this.Orphans            = orphans;
     this.Validator          = validator;
     this.mempoolPersistence = mempoolPersistence;
     this.mempoolLogger      = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Beispiel #5
0
        private void CheckFee(MempoolValidationContext context)
        {
            Money mempoolRejectFee = this.memPool.GetMinFee(this.nodeArgs.Mempool.MaxMempool * 1000000).GetFee(context.EntrySize);

            if (mempoolRejectFee > 0 && context.ModifiedFees < mempoolRejectFee)
            {
                context.State.Fail(MempoolErrors.MinFeeNotMet, $" {context.Fees} < {mempoolRejectFee}").Throw();
            }
            else if (this.nodeArgs.Mempool.RelayPriority && context.ModifiedFees < MinRelayTxFee.GetFee(context.EntrySize) &&
                     !TxMempool.AllowFree(context.Entry.GetPriority(this.chain.Height + 1)))
            {
                // Require that free transactions have sufficient priority to be mined in the next block.
                context.State.Fail(MempoolErrors.InsufficientPriority).Throw();
            }

            if (context.State.AbsurdFee > 0 && context.Fees > context.State.AbsurdFee)
            {
                context.State.Invalid(MempoolErrors.AbsurdlyHighFee, $"{context.Fees} > {context.State.AbsurdFee}").Throw();
            }
        }
 /// <summary>
 /// Constructs an instance of a memory pool manager object.
 /// </summary>
 /// <param name="mempoolLock">A lock for managing asynchronous access to memory pool.</param>
 /// <param name="memPool">Transaction memory pool for managing transactions in the memory pool.</param>
 /// <param name="validator">Memory pool validator for validating transactions.</param>
 /// <param name="orphans">Memory pool orphans for managing orphan transactions.</param>
 /// <param name="dateTimeProvider">Date and time information provider.</param>
 /// <param name="nodeArgs">Settings from the node.</param>
 /// <param name="mempoolSettings">Settings for memory pool.</param>
 /// <param name="mempoolPersistence">Memory pool persistence methods for loading and saving from storage.</param>
 /// <param name="loggerFactory">Logger factory for creating instance logger.</param>
 public MempoolManager(
     MempoolSchedulerLock mempoolLock,
     TxMempool memPool,
     IMempoolValidator validator,
     MempoolOrphans orphans,
     IDateTimeProvider dateTimeProvider,
     MempoolSettings mempoolSettings,
     IMempoolPersistence mempoolPersistence,
     CoinView coinView,
     ILoggerFactory loggerFactory)
 {
     this.MempoolLock        = mempoolLock;
     this.memPool            = memPool;
     this.DateTimeProvider   = dateTimeProvider;
     this.mempoolSettings    = mempoolSettings;
     this.Orphans            = orphans;
     this.Validator          = validator;
     this.mempoolPersistence = mempoolPersistence;
     this.coinView           = coinView;
     this.mempoolLogger      = loggerFactory.CreateLogger(this.GetType().FullName);
 }
 public MempoolValidator(
     TxMempool memPool,
     MempoolScheduler mempoolScheduler,
     PowConsensusValidator consensusValidator,
     IDateTimeProvider dateTimeProvider,
     NodeSettings nodeArgs,
     ConcurrentChain chain,
     CoinView coinView,
     ILoggerFactory loggerFactory)
 {
     this.memPool            = memPool;
     this.mempoolScheduler   = mempoolScheduler;
     this.consensusValidator = consensusValidator;
     this.dateTimeProvider   = dateTimeProvider;
     this.nodeArgs           = nodeArgs;
     this.chain              = chain;
     this.coinView           = coinView;
     this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
     this.freeLimiter        = new FreeLimiterSection();
     this.PerformanceCounter = new MempoolPerformanceCounter();
 }