Merge pull request #635 from jl777/jl777

Jl777
This commit is contained in:
jl777
2018-04-27 15:21:30 +03:00
committed by GitHub
2 changed files with 4 additions and 2 deletions

View File

@@ -45,7 +45,9 @@ 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;
tree = (bits256 *)calloc(MoMdepth,sizeof(*tree));
if ( MoMdepth >= height )
return(zero);
tree = (bits256 *)calloc(MoMdepth * 3,sizeof(*tree));
for (i=0; i<MoMdepth; i++)
{
if ( (pindex= komodo_chainactive(height - i)) != 0 )

View File

@@ -876,7 +876,7 @@ UniValue calc_MoM(const UniValue& params, bool fHelp)
LOCK(cs_main);
height = atoi(params[0].get_str().c_str());
MoMdepth = atoi(params[1].get_str().c_str());
if ( height <= 0 || MoMdepth <= 0 )
if ( height <= 0 || MoMdepth <= 0 || MoMdepth >= height )
throw runtime_error("calc_MoM illegal height or MoMdepth\n");
//fprintf(stderr,"height_MoM height.%d\n",height);
MoM = komodo_calcMoM(height,MoMdepth);