diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 263c45d71..64e87ea21 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -423,7 +423,7 @@ int32_t NSPV_gettxproof(struct NSPV_txproof *ptr,int32_t vout,uint256 txid,int32 else { ptr->height = height; - if ((pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 ) + if ( (pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 ) { BOOST_FOREACH(const CTransaction&tx, block.vtx) { @@ -576,7 +576,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req else { isCC = (request[len-9] != 0); - iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); + iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); } if ( isCC != 0 ) @@ -616,7 +616,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req else { isCC = (request[len-9] != 0); - iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); + iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); } //if ( isCC != 0 ) diff --git a/src/main.cpp b/src/main.cpp index 8c8581b16..700eb6c75 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7503,7 +7503,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } else if (strCommand == "getnSPV") { - if ( KOMODO_NSPV == 0 && KOMODO_INSYNC != 0 ) + if ( KOMODO_NSPV == 0 )//&& KOMODO_INSYNC != 0 ) { std::vector payload; vRecv >> payload; diff --git a/src/pow.cpp b/src/pow.cpp index a99fcc05c..95cda4443 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -167,8 +167,11 @@ arith_uint256 oldRT_CST_RST(int32_t height,uint32_t nTime,arith_uint256 bnTarget arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past) { - int64_t outerK; arith_uint256 mintarget = bnTarget / arith_uint256(2); - if ( (ts[0] - ts[W]) < (T * numerator)/denominator ) + int64_t outerK; int32_t cmpval; arith_uint256 mintarget = bnTarget / arith_uint256(2); + cmpval = (T * numerator)/denominator; + if ( cmpval < 2 ) + cmpval = 2; + if ( (ts[0] - ts[W]) < cmpval ) { outerK = (K * (nTime-ts[0]) * (ts[0]-ts[W]) * denominator) / (numerator * (T * T)); if ( outerK < K ) @@ -209,13 +212,14 @@ arith_uint256 RT_CST_RST_target(int32_t height,uint32_t nTime,arith_uint256 bnTa arith_uint256 RT_CST_RST_inner(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t W,int32_t outeri) { - arith_uint256 mintarget; int32_t expected,elapsed,width = outeri+W; + int32_t expected,elapsed,width = outeri+W; arith_uint256 mintarget,origtarget; expected = (width+1) * T; + origtarget = bnTarget; if ( (elapsed= (ts[0] - ts[width])) < expected ) { - mintarget = (bnTarget / arith_uint256(11)) * arith_uint256(10); + mintarget = (bnTarget / arith_uint256(101)) * arith_uint256(100); bnTarget = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W); - if ( bnTarget > mintarget ) // force zawyflag to 1 + if ( bnTarget == origtarget ) // force zawyflag to 1 bnTarget = mintarget; { int32_t z; @@ -397,6 +401,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead origtarget = bnTarget; if ( zflags[0] == 0 || zflags[0] == 3 ) { + // 15 51 102 162 230 303 380 460 543 627 714 803 892 983 1075 These are the 0.5% per blk numerator constants for W=2 to 16 if denominator is 100. - zawy if ( ASSETCHAINS_BLOCKTIME >= 60 && ASSETCHAINS_BLOCKTIME < 100 ) bnTarget = RT_CST_RST_outer(height,pblock->nTime,bnTarget,ts,ct,1,60,1,10); else if ( ASSETCHAINS_BLOCKTIME >= 100 )