Sync with latest Komodo changes

This commit is contained in:
Michael Toutonghi
2018-08-06 12:52:22 -07:00
150 changed files with 10076 additions and 2162 deletions

View File

@@ -21,7 +21,7 @@
#endif // ENABLE_RUST
uint32_t komodo_chainactive_timestamp();
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH;
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_STAKED;
extern char ASSETCHAINS_SYMBOL[65];
extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD;
unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params);
@@ -306,6 +306,8 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
unsigned int n = params.EquihashN();
unsigned int k = params.EquihashK();
if ( Params().NetworkIDString() == "regtest" )
return(true);
// Hash state
crypto_generichash_blake2b_state state;
EhInitialiseState(n, k, state);
@@ -390,7 +392,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
else if ( height >= 80000 && height < 108000 && special2 > 0 )
flag = 1;
else if ( height >= 108000 && special2 > 0 )
flag = ((height % KOMODO_ELECTION_GAP) > 64 || (height % KOMODO_ELECTION_GAP) == 0);
flag = (height > 1000000 || (height % KOMODO_ELECTION_GAP) > 64 || (height % KOMODO_ELECTION_GAP) == 0);
else if ( height == 790833 )
flag = 1;
else if ( special2 < 0 )
@@ -409,7 +411,11 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
arith_uint256 bnLimit = (height <= 1 || ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) ? UintToArith256(params.powLimit) : UintToArith256(params.powAlternate);
if (fNegative || bnTarget == 0 || fOverflow || bnTarget > bnLimit)
return error("CheckProofOfWork(): nBits below minimum work");
if ( ASSETCHAINS_STAKED != 0 )
{
arith_uint256 bnMaxPoSdiff;
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
}
// Check proof of work matches claimed amount
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() )
{