From 2a789f1add0278ee24958730d74f076e069ffb2c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Aug 2019 07:57:52 -1100 Subject: [PATCH 1/6] Cmpval --- src/pow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index a99fcc05c..57928d7dc 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 ) From 2c66d1749550cd816510ed2980205ba7d154e61d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Aug 2019 09:11:42 -1100 Subject: [PATCH 2/6] Remove the min target from inner --- src/pow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 57928d7dc..3be08baa1 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -212,14 +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; expected = (width+1) * T; if ( (elapsed= (ts[0] - ts[width])) < expected ) { - mintarget = (bnTarget / arith_uint256(11)) * arith_uint256(10); + //mintarget = (bnTarget / arith_uint256(11)) * arith_uint256(10); bnTarget = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W); - if ( bnTarget > mintarget ) // force zawyflag to 1 - bnTarget = mintarget; + //if ( bnTarget > mintarget ) // force zawyflag to 1 + // bnTarget = mintarget; { int32_t z; for (z=31; z>=0; z--) From b124da71db35901443a72680d9f58ebca2765225 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Aug 2019 21:05:30 -1100 Subject: [PATCH 3/6] Force min target --- src/pow.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 3be08baa1..c037b5ba5 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -212,14 +212,15 @@ 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) { - int32_t expected,elapsed,width = outeri+W; //arith_uint256 mintarget; + 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 - // bnTarget = mintarget; + if ( bnTarget == origtarget ) // force zawyflag to 1 + bnTarget = mintarget; { int32_t z; for (z=31; z>=0; z--) From 450ac5c5ea758de4b6ae4a858e811c54ca984983 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Aug 2019 03:51:21 -1100 Subject: [PATCH 4/6] Fix skip count --- src/komodo_nSPV_fullnode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 263c45d71..008495188 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -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 ) From 0c680e0dbcac3c94d6e6dfde4015e0324f27cd37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Aug 2019 23:29:46 -1100 Subject: [PATCH 5/6] -insync test for getNSPV --- src/komodo_nSPV_fullnode.h | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 008495188..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) { 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; From 10199d2765a01c6c11a6e74ad764e3b42a8113ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 12 Aug 2019 00:14:06 -1100 Subject: [PATCH 6/6] +zawy constants --- src/pow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pow.cpp b/src/pow.cpp index c037b5ba5..95cda4443 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -401,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 )