diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index bc5fb1057..0306b434e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -811,9 +811,23 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33],uint32_t timestamp return(0); } +int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,int32_t nHeight) +{ + int32_t depth,notarized_ht; uint256 MoM; + depth = komodo_MoMdata(¬arized_ht,&MoM,nHeight); + memset(MoMp,0,sizeof(*MoMp)); + *notarized_heightp = 0; + if ( depth > 0 && notarized_ht > 0 && nHeight > notarized_ht-depth && nHeight < notarized_ht ) + { + *MoMp = MoM; + *notarized_heightp = notarized_ht; + } + return(depth); +} + int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) { - int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary; CBlockIndex *pindex; + int32_t notarized_height,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; CBlockIndex *notary; CBlockIndex *pindex; if ( (pindex= chainActive.Tip()) == 0 ) return(-1); notarized_height = komodo_notarizeddata(pindex->nHeight,¬arized_hash,¬arized_desttxid); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index f30f388e7..1f2f21005 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -398,6 +398,26 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp) } } +int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,int32_t nHeight) +{ + struct komodo_state *sp; struct notarized_checkpoint *np = 0; + np = 0; + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( np->MoMdepth > 0 && nHeight > np->nHeight-np->MoMdepth && nHeight <= np->nHeight ) + { + printf("komodo_MoMdata %d i.%d np->ht %d MoMdepth.%d\n",nHeight,i,np->nHeight,np->MoMdepth); + *notarized_htp = np->nHeight; + *MoMp = np->MoM; + return(np->MoMdepth); + } + } + *notarized_htp = 0; + memset(MoMp,0,sizeof(*MoMp)); + return(0); +} + int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) { struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;