From b7be25e2d5f4fa33d282d817263d1363bdfd5686 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 26 Jun 2021 14:42:40 -0400 Subject: [PATCH] Thanks to hellcatz for this patch --- src/main.cpp | 2 +- src/rpc/net.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 94b41fe5a..ec02f3a79 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4025,7 +4025,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1; LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); - if ( HUSH_LONGESTCHAIN != 0 && (pindexNew->GetHeight() == HUSH_LONGESTCHAIN || pindexNew->GetHeight() == HUSH_LONGESTCHAIN+1) ) + if ( HUSH_LONGESTCHAIN != 0 && (pindexNew->GetHeight() >= HUSH_LONGESTCHAIN )) HUSH_INSYNC = (int32_t)pindexNew->GetHeight(); else HUSH_INSYNC = 0; //fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),HUSH_INSYNC,ASSETCHAINS_SAPLING); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 6ea9819a8..4533b0196 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -180,15 +180,15 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) } int32_t HUSH_LONGESTCHAIN; +static int32_t hush_longest_depth = 0; int32_t hush_longestchain() { - static int32_t depth; int32_t ht,n=0,num=0,maxheight=0,height = 0; - if ( depth < 0 ) - depth = 0; - if ( depth == 0 ) + if ( hush_longest_depth < 0 ) + hush_longest_depth = 0; + if ( hush_longest_depth == 0 ) { - depth++; + hush_longest_depth++; vector vstats; { //LOCK(cs_main); @@ -215,7 +215,7 @@ int32_t hush_longestchain() if ( ht > height ) height = ht; } - depth--; + hush_longest_depth--; if ( num > (n >> 1) ) { if ( 0 && height != HUSH_LONGESTCHAIN )