From 99d4a96f87287e04689f4d3f98975a8d7dcf81ca Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Wed, 16 Sep 2015 15:51:18 +0300 Subject: [PATCH] nBlockTrust cleanup. --- Novacoin/DatabaseObjects.cs | 28 +++++++++++----------------- Novacoin/NetInfo.cs | 5 ----- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/Novacoin/DatabaseObjects.cs b/Novacoin/DatabaseObjects.cs index 57a47bd..b12d681 100644 --- a/Novacoin/DatabaseObjects.cs +++ b/Novacoin/DatabaseObjects.cs @@ -405,26 +405,14 @@ namespace Novacoin { get { - uint256 nTarget = 0; - nTarget.Compact = nBits; - - /* Old protocol */ - if (nTime < NetInfo.nChainChecksSwitchTime) + // Return 1 for the first 12 blocks + if (prev == null || prev.nHeight < 12) { - return IsProofOfStake ? (new uint256(1) << 256) / (nTarget + 1) : 1; + return 1; } - /* New protocol */ - - // Calculate work amount for block - var nPoWTrust = NetInfo.nPoWBase / (nTarget + 1); - - // Set nPowTrust to 1 if we are checking PoS block or PoW difficulty is too low - nPoWTrust = (IsProofOfStake || !nPoWTrust) ? 1 : nPoWTrust; - - // Return nPoWTrust for the first 12 blocks - if (prev == null || prev.nHeight < 12) - return nPoWTrust; + uint256 nTarget = 0; + nTarget.Compact = nBits; CBlockStoreItem currentIndex = prev; @@ -460,6 +448,12 @@ namespace Novacoin } else { + // Calculate work amount for block + var nPoWTrust = NetInfo.nPoWBase / (nTarget + 1); + + // Set nPowTrust to 1 if we are checking PoS block or PoW difficulty is too low + nPoWTrust = (IsProofOfStake || !nPoWTrust) ? 1 : nPoWTrust; + var nLastBlockTrust = prev.nChainTrust - prev.prev.nChainTrust; // Return nPoWTrust + 2/3 of previous block score if two parent blocks are not PoS blocks diff --git a/Novacoin/NetInfo.cs b/Novacoin/NetInfo.cs index 97d83e8..ef74166 100644 --- a/Novacoin/NetInfo.cs +++ b/Novacoin/NetInfo.cs @@ -36,11 +36,6 @@ public static uint256 nPoWBase = new uint256("00000000ffff0000000000000000000000000000000000000000000000000000"); /// - /// Fri, 20 Sep 2013 00:00:00 GMT - /// - public const uint nChainChecksSwitchTime = 1379635200; - - /// /// Sat, 20 Jul 2013 00:00:00 GMT /// public const uint nTargetsSwitchTime = 1374278400; -- 1.7.1