From b0fa5bad4d808abfc7f6239279ff0da0863a8f7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Apr 2018 13:16:37 +0300 Subject: [PATCH] calc_MoM --- src/komodo_ccdata.h | 21 ++++++++++++++++++++- src/rpcblockchain.cpp | 20 ++++++++++++++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 32db78283..545c8b87a 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -42,6 +42,25 @@ bits256 iguana_merkle(bits256 *tree,int32_t txn_count) return(tree[n]); } +uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) +{ + static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; + tree = (bits256 *)calloc(MoMdepth,sizeof(*tree)); + for (i=0; ihashMerkleRoot,sizeof(bits256)); + else + { + free(tree); + return(zero); + } + } + MoM = iguana_merkle(tree,MoMdepth); + free(tree); + return(*(uint256 *)&MoM); +} + struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi) { struct komodo_ccdata_entry *allMoMs=0; bits256 *tree,tmp; struct komodo_ccdata *ccdata,*tmpptr; int32_t i,num,max; @@ -73,7 +92,7 @@ struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t for (i=0; i