diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0ae61356f..327761c00 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -448,6 +448,18 @@ int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len, return(-1); } +void komodo_reconsiderblock(uint256 blockhash) +{ + char params[256],*jsonstr,*hexstr; + sprintf(params,"[\"%s\"]",blockhash.ToString().c_str()); + komodo_reconsiderblock(Queued_reconsiderblock); + if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"reconsiderblock",params,KMD_PORT)) != 0 ) + { + fprintf(stderr,"komodo_reconsiderblock.(%s) -> (%s)\n",params,jsonstr); + free(jsonstr); + } +} + int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) { char params[256],*jsonstr,*hexstr; uint8_t *script,_script[8192]; int32_t n,len,retval = -1; cJSON *json,*txjson,*vouts,*vout,*skey; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5d5f74155..f23a2ff8f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -2625,10 +2625,17 @@ void komodo_pricesinit() } } +extern Queued_reconsiderblock; + void komodo_pricesupdate(int32_t height,CBlock *pblock) { static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf; int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[PRICES_MAXDATAPOINTS*2]; + if ( Queued_reconsiderblock != zeroid ) + { + komodo_reconsiderblock(Queued_reconsiderblock); + Queued_reconsiderblock = zeroid; + } width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH); if ( numprices == 0 ) { diff --git a/src/main.cpp b/src/main.cpp index fdd9d3132..d01c9babb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5273,6 +5273,8 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat return true; } +uint256 Queued_reconsiderblock; + bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, CBlockIndex** ppindex, bool fRequested, CDiskBlockPos* dbp) { const CChainParams& chainparams = Params(); @@ -5336,12 +5338,13 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C if ( ASSETCHAINS_CBOPRET != 0 ) { CValidationState tmpstate; CBlockIndex *tmpindex; int32_t ht,longest; - ht = (int32_t)pindex->GetHeight()-1; + ht = (int32_t)pindex->GetHeight(); longest = komodo_longestchain(); if ( (longest == 0 || ht < longest-6) && (tmpindex=komodo_chainactive(ht)) != 0 ) { fprintf(stderr,"reconsider height.%d, longest.%d\n",(int32_t)ht,longest); - InvalidateBlock(tmpstate,tmpindex); + if ( Queued_reconsiderblock == zeroid ) + Queued_reconsiderblock = pindex->GetHash(); } } }