diff --git a/src/komodo.h b/src/komodo.h index 23d53941e..174a13e1a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -278,7 +278,7 @@ uint64_t komodo_interest(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { minutes = (tiptime - nLockTime) / 60; days = minutes / (24 * 60); - interest = (nValue * 5000000) / (((uint64_t)365 * 1000000 * 24 * 60) / minutes); + interest = (nValue * 5000000) / (((uint64_t)365 * 100000000 * 24 * 60) / minutes); fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d days.%d interest %lld %.8f\n",(long long)nValue,(double)nValue/100000000.,nLockTime,tiptime,minutes,days,(long long)interest,(double)interest/100000000); } return(interest * 0); diff --git a/src/main.cpp b/src/main.cpp index fc20e557a..254053a90 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3079,19 +3079,26 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight)); else { - int32_t notarized_height; uint256 notarized_hash,notarized_btctxid; + int32_t notarized_height; uint256 notarized_hash,notarized_btctxid; CBlockIndex *notary; notarized_height = komodo_notarizeddata(chainActive.Tip()->nHeight,¬arized_hash,¬arized_btctxid); - //printf("nHeight.%d -> (%d %s)\n",chainActive.Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); - if ( nHeight < notarized_height ) + if ( (notary= mapBlockIndex[notarized_hash]) != 0 ) { - fprintf(stderr,"nHeight.%d < NOTARIZED_HEIGHT.%d\n",nHeight,notarized_height); - return state.DoS(100, error("%s: forked chain older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); - } - else if ( nHeight == notarized_height && memcmp(&hash,¬arized_hash,sizeof(hash)) != 0 ) - { - fprintf(stderr,"nHeight.%d == NOTARIZED_HEIGHT.%d, diff hash\n",nHeight,notarized_height); - return state.DoS(100, error("%s: forked chain at notarized (height %d) with different hash", __func__, notarized_height)); - } + //printf("nHeight.%d -> (%d %s)\n",chainActive.Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); + if ( notary->nHeight == notarized_height ) // if notarized_hash not in chain, reorg + { + if ( nHeight < notarized_height ) + { + fprintf(stderr,"nHeight.%d < NOTARIZED_HEIGHT.%d\n",nHeight,notarized_height); + return state.DoS(100, error("%s: forked chain older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); + } + else if ( nHeight == notarized_height && memcmp(&hash,¬arized_hash,sizeof(hash)) != 0 ) + { + fprintf(stderr,"nHeight.%d == NOTARIZED_HEIGHT.%d, diff hash\n",nHeight,notarized_height); + return state.DoS(100, error("%s: forked chain at notarized (height %d) with different hash", __func__, notarized_height)); + } + } else fprintf(stderr,"notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); + } else if ( notarized_height > 0 ) + fprintf(stderr,"couldnt find notary_hash %s ht.%d\n",notarized_hash.ToString().c_str(),notarized_height); } }