From ac09a89f9764fb1ffc8bca5d87d2c7d153a3fdd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 03:54:47 -1100 Subject: [PATCH 01/11] Test --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8d1649d3b..f533b7761 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6826,9 +6826,11 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (pindexBestHeader == NULL) pindexBestHeader = chainActive.Tip(); bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. - if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { + if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) + { // Only actively request headers from a single peer, unless we're close to today. - if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { + if ((nSyncStarted == 0 && fFetch) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) + { state.fSyncStarted = true; nSyncStarted++; CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; From 20a1f68495067de1150a6d315c2351239c3857d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 04:01:37 -1100 Subject: [PATCH 02/11] +print --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index f533b7761..93bcb0421 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6826,8 +6826,10 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (pindexBestHeader == NULL) pindexBestHeader = chainActive.Tip(); bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. + fprintf(stderr,"see if can request\n"); if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { + fprintf(stderr,"check for asking initial headers: nSyncStarted.%d fFetch.%d\n",(int32_t)nSyncStarted,(int32_t)fFetch); // Only actively request headers from a single peer, unless we're close to today. if ((nSyncStarted == 0 && fFetch) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { From 3a796a89aa1f0f0e13daa584d9137395eee11e4f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 04:07:53 -1100 Subject: [PATCH 03/11] Prints --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 93bcb0421..c4cbcc751 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6826,16 +6826,16 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (pindexBestHeader == NULL) pindexBestHeader = chainActive.Tip(); bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. - fprintf(stderr,"see if can request\n"); + //fprintf(stderr,"see if can request\n"); if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { - fprintf(stderr,"check for asking initial headers: nSyncStarted.%d fFetch.%d\n",(int32_t)nSyncStarted,(int32_t)fFetch); // Only actively request headers from a single peer, unless we're close to today. - if ((nSyncStarted == 0 && fFetch) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) + if ((nSyncStarted < 3 && fFetch) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; + fprintf(stderr,"ask initial headers: nSyncStarted.%d fFetch.%d peer.%d [%d to %d]\n",(int32_t)nSyncStarted,(int32_t)fFetch,pto->id, pto->nStartingHeight,pindexStart->nHeight); LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight); pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); } From 3df89af7feddbe125b7095aa69df42bb2c82c05d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 04:16:09 -1100 Subject: [PATCH 04/11] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c4cbcc751..e517d8a6e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6830,7 +6830,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { // Only actively request headers from a single peer, unless we're close to today. - if ((nSyncStarted < 3 && fFetch) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) + if ((nSyncStarted < 30 && fFetch) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; From 18c515eb032f5e1bfbc5405e6bf76699e8375a47 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 04:20:21 -1100 Subject: [PATCH 05/11] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e517d8a6e..2b820f1b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6827,15 +6827,15 @@ bool SendMessages(CNode* pto, bool fSendTrickle) pindexBestHeader = chainActive.Tip(); bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. //fprintf(stderr,"see if can request\n"); - if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) + if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pto->nStartingHeight != 0 ) { // Only actively request headers from a single peer, unless we're close to today. - if ((nSyncStarted < 30 && fFetch) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) + if ( (nSyncStarted < 30 && (fFetch || pindexStart->nHeight == 0) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; - fprintf(stderr,"ask initial headers: nSyncStarted.%d fFetch.%d peer.%d [%d to %d]\n",(int32_t)nSyncStarted,(int32_t)fFetch,pto->id, pto->nStartingHeight,pindexStart->nHeight); + fprintf(stderr,"ask initial headers: nSyncStarted.%d fFetch.%d peer.%d [%d to %d]\n",(int32_t)nSyncStarted,(int32_t)fFetch,pto->id, pindexStart->nHeight,pto->nStartingHeight); LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight); pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); } From 8d124e7f5059d8e362892bba322996e040e5151a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 04:24:47 -1100 Subject: [PATCH 06/11] syntax --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 2b820f1b2..80d9e533f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6830,7 +6830,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pto->nStartingHeight != 0 ) { // Only actively request headers from a single peer, unless we're close to today. - if ( (nSyncStarted < 30 && (fFetch || pindexStart->nHeight == 0) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) + if ( nSyncStarted < 30 && (fFetch || pindexStart->nHeight == 0) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; From 7aa8bcb497e7acb230c7537574fd0b03fabd19e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 04:28:34 -1100 Subject: [PATCH 07/11] Syntax --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 80d9e533f..a083f65e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6829,12 +6829,12 @@ bool SendMessages(CNode* pto, bool fSendTrickle) //fprintf(stderr,"see if can request\n"); if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pto->nStartingHeight != 0 ) { + CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; // Only actively request headers from a single peer, unless we're close to today. if ( nSyncStarted < 30 && (fFetch || pindexStart->nHeight == 0) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; - CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; fprintf(stderr,"ask initial headers: nSyncStarted.%d fFetch.%d peer.%d [%d to %d]\n",(int32_t)nSyncStarted,(int32_t)fFetch,pto->id, pindexStart->nHeight,pto->nStartingHeight); LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight); pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); From 2a46683da275aa0cae25b366655fe9dc9a30903b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 04:32:12 -1100 Subject: [PATCH 08/11] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a083f65e3..89a0551dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6831,7 +6831,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) { CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; // Only actively request headers from a single peer, unless we're close to today. - if ( nSyncStarted < 30 && (fFetch || pindexStart->nHeight == 0) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) + if ( nSyncStarted < 3 && (fFetch || pindexStart->nHeight == 0) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; From e9b849601d3967fa11eedfa3ea882e40f3c905f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 05:27:09 -1100 Subject: [PATCH 09/11] Revert init headers tweaks --- src/main.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 89a0551dd..8d1649d3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6826,16 +6826,12 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (pindexBestHeader == NULL) pindexBestHeader = chainActive.Tip(); bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. - //fprintf(stderr,"see if can request\n"); - if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pto->nStartingHeight != 0 ) - { - CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; + if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { // Only actively request headers from a single peer, unless we're close to today. - if ( nSyncStarted < 3 && (fFetch || pindexStart->nHeight == 0) )//|| pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) - { + if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; - fprintf(stderr,"ask initial headers: nSyncStarted.%d fFetch.%d peer.%d [%d to %d]\n",(int32_t)nSyncStarted,(int32_t)fFetch,pto->id, pindexStart->nHeight,pto->nStartingHeight); + CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight); pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); } From 9c2f6f11bb3c45991e1b4a294aa0130b17404d76 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 05:44:54 -1100 Subject: [PATCH 10/11] Work around inadvertent CPU mining --- src/komodo_bitcoind.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5cd88d7de..0f49c3758 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1248,13 +1248,16 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ { CBlockIndex *previndex; char voutaddr[64],destaddr[64]; uint256 txid; uint32_t txtime,prevtime=0; int32_t vout,txn_count,eligible,isPoS = 0; uint64_t value; CTxDestination voutaddress; txn_count = pblock->vtx.size(); - if ( txn_count > 1 ) + if ( ASSETCHAINS_STAKED == 100 && height < 1000 ) + return(1); + if ( txn_count > 1 && pblock->vtx[txn_count-1].vout.size() == 1 ) { if ( prevtime == 0 ) { if ( (previndex= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) prevtime = (uint32_t)previndex->nTime; } + // add strict check for 100% of vin -> vout txid = pblock->vtx[txn_count-1].vin[0].prevout.hash; vout = pblock->vtx[txn_count-1].vin[0].prevout.n; if ( prevtime != 0 ) @@ -1265,7 +1268,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ fprintf(stderr,"komodo_is_PoSblock PoS failure ht.%d eligible.%u vs blocktime.%u, lag.%d -> check to see if it is PoW block\n",height,eligible,(uint32_t)pblock->nTime,(int32_t)(eligible - pblock->nTime)); } else isPoS = 1; } - else if ( slowflag == 0 ) // maybe previous block is not seen yet, do the best approx + if ( slowflag == 0 ) // maybe previous block is not seen yet, do the best approx { txtime = komodo_txtime(&value,txid,vout,destaddr); if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) ) From c6d2cccf9231989c5cd4b1fdbe08a98f6a282785 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Jul 2018 05:49:19 -1100 Subject: [PATCH 11/11] -print --- src/komodo_bitcoind.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0f49c3758..cfa4c7c33 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1257,7 +1257,6 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ if ( (previndex= mapBlockIndex[pblock->hashPrevBlock]) != 0 ) prevtime = (uint32_t)previndex->nTime; } - // add strict check for 100% of vin -> vout txid = pblock->vtx[txn_count-1].vin[0].prevout.hash; vout = pblock->vtx[txn_count-1].vin[0].prevout.n; if ( prevtime != 0 )