From 1b9f98cd1980493f995c5c1bef0f12d8b81c0397 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 30 May 2018 12:57:21 -1100 Subject: [PATCH] Truncate MoMdepth --- src/komodo_bitcoind.h | 2 +- src/komodo_ccdata.h | 1 + src/komodo_notary.h | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5b19dfb6f..24f510b8b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -932,7 +932,7 @@ int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,in memset(MoMp,0,sizeof(*MoMp)); memset(kmdtxidp,0,sizeof(*kmdtxidp)); *notarized_heightp = 0; - if ( depth > 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht ) + if ( depth != 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight <= notarized_ht ) { *MoMp = MoM; *notarized_heightp = notarized_ht; diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 058e38cee..6e7d0fabe 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -45,6 +45,7 @@ bits256 iguana_merkle(bits256 *tree,int32_t txn_count) uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) { static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; int32_t i; + MoMdepth &= 0xffff; if ( MoMdepth >= height ) return(zero); tree = (bits256 *)calloc(MoMdepth * 3,sizeof(*tree)); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 25a03f83b..f83f85afe 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -392,7 +392,7 @@ struct notarized_checkpoint *komodo_npptr(int32_t height) for (i=sp->NUM_NPOINTS-1; i>=0; i--) { np = &sp->NPOINTS[i]; - if ( np->MoMdepth > 0 && height > np->notarized_height-np->MoMdepth && height <= np->notarized_height ) + if ( np->MoMdepth != 0 && height > np->notarized_height-(np->MoMdepth&0xffff) && height <= np->notarized_height ) return(np); } } @@ -447,7 +447,7 @@ int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,in *MoMoMdepthp = np->MoMoMdepth; *kmdstartip = np->kmdstarti; *kmdendip = np->kmdendi; - return(np->MoMdepth); + return(np->MoMdepth & 0xffff); } *notarized_htp = *MoMoMoffsetp = *MoMoMdepthp = *kmdstartip = *kmdendip = 0; memset(MoMp,0,sizeof(*MoMp));