Ejemplo n.º 1
0
        /// <summary>
        /// Initializes an instance of the object from the node configuration.
        /// </summary>
        /// <param name="nodeSettings">The node configuration.</param>
        public MinerSettings(NodeSettings nodeSettings)
        {
            Guard.NotNull(nodeSettings, nameof(nodeSettings));

            this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(MinerSettings).FullName);
            this.logger.LogTrace("({0}:'{1}')", nameof(nodeSettings), nodeSettings.Network.Name);

            TextFileConfiguration config = nodeSettings.ConfigReader;

            this.Mine = config.GetOrDefault <bool>("mine", false, this.logger);
            if (this.Mine)
            {
                this.MineAddress = config.GetOrDefault <string>("mineaddress", null, this.logger);
            }

            this.Stake = config.GetOrDefault <bool>("stake", false, this.logger);
            if (this.Stake)
            {
                this.WalletName     = config.GetOrDefault <string>("walletname", null, this.logger);
                this.WalletPassword = config.GetOrDefault <string>("walletpassword", null); // No logging!
            }

            uint blockMaxSize   = (uint)config.GetOrDefault <int>("blockmaxsize", (int)nodeSettings.Network.Consensus.Options.MaxBlockSerializedSize, this.logger);
            uint blockMaxWeight = (uint)config.GetOrDefault <int>("blockmaxweight", (int)nodeSettings.Network.Consensus.Options.MaxBlockWeight, this.logger);

            this.BlockDefinitionOptions = new BlockDefinitionOptions(blockMaxWeight, blockMaxSize).RestrictForNetwork(nodeSettings.Network);

            this.logger.LogTrace("(-)");
        }
Ejemplo n.º 2
0
        protected BlockDefinition(
            IConsensusManager consensusManager,
            IDateTimeProvider dateTimeProvider,
            ILoggerFactory loggerFactory,
            ITxMempool mempool,
            MempoolSchedulerLock mempoolLock,
            MinerSettings minerSettings,
            Network network,
            NodeDeployments nodeDeployments)
        {
            this.ConsensusManager = consensusManager;
            this.DateTimeProvider = dateTimeProvider;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.Mempool          = mempool;
            this.MempoolLock      = mempoolLock;
            this.Network          = network;
            this.nodeDeployments  = nodeDeployments;

            this.Options         = minerSettings.BlockDefinitionOptions;
            this.BlockMinFeeRate = this.Options.BlockMinFeeRate;

            // Whether we need to account for byte usage (in addition to weight usage).
            this.NeedSizeAccounting = (this.Options.BlockMaxSize < network.Consensus.Options.MaxBlockSerializedSize);

            this.Configure();
        }
Ejemplo n.º 3
0
        protected BlockDefinition(
            IConsensusLoop consensusLoop,
            IDateTimeProvider dateTimeProvider,
            ILoggerFactory loggerFactory,
            ITxMempool mempool,
            MempoolSchedulerLock mempoolLock,
            Network network,
            BlockDefinitionOptions options = null)
        {
            this.ConsensusLoop    = consensusLoop;
            this.DateTimeProvider = dateTimeProvider;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.Mempool          = mempool;
            this.MempoolLock      = mempoolLock;
            this.Network          = network;

            this.Options         = options ?? new BlockDefinitionOptions();
            this.BlockMinFeeRate = this.Options.BlockMinFeeRate;

            // Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity.
            this.BlockMaxWeight = (uint)Math.Max(4000, Math.Min(PowMining.DefaultBlockMaxWeight - 4000, this.Options.BlockMaxWeight));

            // Limit size to between 1K and MAX_BLOCK_SERIALIZED_SIZE-1K for sanity.
            this.BlockMaxSize = (uint)Math.Max(1000, Math.Min(network.Consensus.Option <PowConsensusOptions>().MaxBlockSerializedSize - 1000, this.Options.BlockMaxSize));

            // Whether we need to account for byte usage (in addition to weight usage).
            this.NeedSizeAccounting = (this.BlockMaxSize < network.Consensus.Option <PowConsensusOptions>().MaxBlockSerializedSize - 1000);

            this.Configure();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes an instance of the object from the node configuration.
        /// </summary>
        /// <param name="nodeSettings">The node configuration.</param>
        public MinerSettings(NodeSettings nodeSettings)
        {
            Guard.NotNull(nodeSettings, nameof(nodeSettings));

            this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(MinerSettings).FullName);

            TextFileConfiguration config = nodeSettings.ConfigReader;

            this.Mine = config.GetOrDefault <bool>("mine", false, this.logger);
            if (this.Mine)
            {
                this.MineAddress = config.GetOrDefault <string>("mineaddress", null, this.logger);
            }

            this.Stake = config.GetOrDefault <bool>("stake", false, this.logger);
            if (this.Stake)
            {
                this.WalletName     = config.GetOrDefault <string>("walletname", null, this.logger);
                this.WalletPassword = config.GetOrDefault <string>("walletpassword", null); // No logging!
            }

            uint blockMaxSize   = (uint)config.GetOrDefault <int>("blockmaxsize", (int)nodeSettings.Network.Consensus.Options.MaxBlockSerializedSize, this.logger);
            uint blockMaxWeight = (uint)config.GetOrDefault <int>("blockmaxweight", (int)nodeSettings.Network.Consensus.Options.MaxBlockWeight, this.logger);

            this.BlockDefinitionOptions = new BlockDefinitionOptions(blockMaxWeight, blockMaxSize).RestrictForNetwork(nodeSettings.Network);

            this.EnableCoinStakeSplitting = config.GetOrDefault("enablecoinstakesplitting", true, this.logger);
            this.MinimumSplitCoinValue    = config.GetOrDefault("minimumsplitcoinvalue", MinimumSplitCoinValueDefaultValue, this.logger);
            this.MinimumStakingCoinValue  = config.GetOrDefault("minimumstakingcoinvalue", MinimumStakingCoinValueDefaultValue, this.logger);
            this.MinimumStakingCoinValue  = this.MinimumStakingCoinValue == 0 ? 1 : this.MinimumStakingCoinValue;
        }
Ejemplo n.º 5
0
 public PowBlockDefinition(
     IConsensusLoop consensusLoop,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     BlockDefinitionOptions options = null)
     : base(consensusLoop, dateTimeProvider, loggerFactory, mempool, mempoolLock, network)
 {
     this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Ejemplo n.º 6
0
 public PowBlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IConsensusRuleEngine consensusRules,
     BlockDefinitionOptions options = null)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network)
 {
     this.consensusRules = consensusRules;
     this.logger         = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
 }
 public PowBlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IConsensusRuleEngine consensusRules,
     NodeDeployments nodeDeployments,
     BlockDefinitionOptions options = null)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, nodeDeployments)
 {
     this.consensusRules = consensusRules;
     this.logger         = loggerFactory.CreateLogger(this.GetType().FullName);
 }