コード例 #1
0
ファイル: PowMining.cs プロジェクト: MithrilMan/xds-1
 public MineBlockContext(ulong amountOfBlocksToMine, ulong chainHeight, ulong maxTries,
                         ReserveScript reserveScript)
 {
     this.amountOfBlocksToMine = amountOfBlocksToMine;
     this.ChainHeight          = chainHeight;
     this.CurrentHeight        = chainHeight;
     this.MaxTries             = maxTries;
     this.ReserveScript        = reserveScript;
 }
コード例 #2
0
ファイル: PowMining.cs プロジェクト: MithrilMan/xds-1
        /// <inheritdoc />
        public List <uint256> GenerateBlocks(ReserveScript reserveScript, ulong amountOfBlocksToMine, ulong maxTries)
        {
            var context = new MineBlockContext(amountOfBlocksToMine, (ulong)this.chainIndexer.Height, maxTries,
                                               reserveScript);

            while (context.MiningCanContinue)
            {
                if (!ConsensusIsAtTip(context))
                {
                    continue;
                }

                if (!BuildBlock(context))
                {
                    continue;
                }

                if (!MineBlock(context))
                {
                    continue;
                }

                if (!ValidateMinedBlock(context))
                {
                    continue;
                }

                if (!ValidateAndConnectBlock(context))
                {
                    continue;
                }

                OnBlockMined(context);
            }

            return(context.Blocks);
        }