Esempio n. 1
0
        /// <summary>
        /// Set time to consensus acceptable value
        /// </summary>
        /// <param name="now">The expected date</param>
        /// <param name="consensus">Consensus</param>
        /// <param name="prev">previous block</param>
        public void UpdateTime(DateTimeOffset now, Consensus consensus, ChainedBlock prev)
        {
            var nOldTime = this.BlockTime;
            var mtp      = prev.GetMedianTimePast() + TimeSpan.FromSeconds(1);
            var nNewTime = mtp > now ? mtp : now;

            if (nOldTime < nNewTime)
            {
                this.BlockTime = nNewTime;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Set time to consensus acceptable value
        /// </summary>
        /// <param name="now">The expected date</param>
        /// <param name="network">Network</param>
        /// <param name="prev">previous block</param>
        public void UpdateTime(DateTimeOffset now, Network network, ChainedBlock prev)
        {
            var nOldTime = this.BlockTime;
            var mtp      = prev.GetMedianTimePast() + TimeSpan.FromSeconds(1);
            var nNewTime = mtp > now ? mtp : now;

            if (nOldTime < nNewTime)
            {
                this.BlockTime = nNewTime;
            }

            // Updating time can change work required on testnet:
            if (network.Consensus.PowAllowMinDifficultyBlocks)
            {
                Bits = GetWorkRequired(network, prev);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Set time to consensus acceptable value.
        /// </summary>
        /// <param name="now">The expected date.</param>
        /// <param name="consensus">Consensus.</param>
        /// <param name="prev">Previous block.</param>
        public void UpdateTime(DateTimeOffset now, Consensus consensus, ChainedBlock prev)
        {
            DateTimeOffset nOldTime = this.BlockTime;
            DateTimeOffset mtp      = prev.GetMedianTimePast() + TimeSpan.FromSeconds(1);
            DateTimeOffset nNewTime = mtp > now ? mtp : now;

            if (nOldTime < nNewTime)
            {
                this.BlockTime = nNewTime;
            }

            // Updating time can change work required on testnet.
            if (consensus.PowAllowMinDifficultyBlocks)
            {
                this.Bits = this.GetWorkRequired(consensus, prev);
            }
        }
Esempio n. 4
0
		/// <summary>
		/// Set time to consensus acceptable value
		/// </summary>
		/// <param name="network">Network</param>
		/// <param name="prev">previous block</param>
		public void UpdateTime(Network network, ChainedBlock prev)
		{
			var nOldTime = this.BlockTime;
			var mtp = prev.GetMedianTimePast() + TimeSpan.FromSeconds(1);
			var now = DateTimeOffset.UtcNow;
			var nNewTime = mtp > now ? mtp : now;

			if(nOldTime < nNewTime)
				this.BlockTime = nNewTime;

			// Updating time can change work required on testnet:
			if(network.Consensus.PowAllowMinDifficultyBlocks)
				Bits = GetWorkRequired(network, prev);
		}