From fe71d39850f86f4d6b90e1429d92a54b538b8b87 Mon Sep 17 00:00:00 2001
From: jl777 <jameslee777@yahoo.com>
Date: Fri, 27 Apr 2018 14:47:57 +0300
Subject: [PATCH 1/3] +MoM print

---
 iguana/dpow/dpow_fsm.c | 2 +-
 iguana/iguana_notary.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c
index 03fc81544..844a9583c 100755
--- a/iguana/dpow/dpow_fsm.c
+++ b/iguana/dpow/dpow_fsm.c
@@ -427,7 +427,7 @@ void dpow_statemachinestart(void *ptr)
         return;
     }
     bp->myind = myind;
-    printf("[%d] notarize %s->%s %s ht.%d minsigs.%d duration.%d start.%u\n",bp->myind,dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration,checkpoint.timestamp);
+    printf("[%d] notarize %s->%s %s ht.%d minsigs.%d duration.%d start.%u MoM[%d] %s\n",bp->myind,dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration,checkpoint.timestamp,bp->MoMdepth,bits256_str(str2,bp->MoM));
     if ( bp->isratify != 0 && memcmp(bp->notaries[0].pubkey,bp->ratified_pubkeys[0],33) != 0 )
     {
         for (i=0; i<33; i++)
diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c
index 142c71619..d614de1b9 100755
--- a/iguana/iguana_notary.c
+++ b/iguana/iguana_notary.c
@@ -60,7 +60,8 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che
 
 void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime)
 {
-    struct komodo_ccdataMoMoM mdata; void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht,notht; uint64_t signedmask; struct dpow_block *bp;
+    //struct komodo_ccdataMoMoM mdata; cJSON *blockjson; uint64_t signedmask; struct iguana_info *coin;
+    void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht;  struct dpow_block *bp;
     dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime);
     checkpoint = dp->srcfifo[dp->srcconfirms];
     if ( strcmp("BTC",dp->dest) == 0 )

From 5c3c3193e4f8aa365c265c033862d9821d3c81ef Mon Sep 17 00:00:00 2001
From: jl777 <jameslee777@yahoo.com>
Date: Fri, 27 Apr 2018 14:48:42 +0300
Subject: [PATCH 2/3] -print

---
 iguana/dpow/dpow_rpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c
index 808970aaf..c9f47ce4d 100755
--- a/iguana/dpow/dpow_rpc.c
+++ b/iguana/dpow/dpow_rpc.c
@@ -235,7 +235,7 @@ cJSON *issue_calcMoM(struct iguana_info *coin,int32_t height,int32_t MoMdepth)
         if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"calc_MoM",buf)) != 0 )
         {
             retjson = cJSON_Parse(retstr);
-            printf("MoM.%s -> %s\n",buf,retstr);
+            //printf("MoM.%s -> %s\n",buf,retstr);
             free(retstr);
         }
     }

From 66f1d11753d30734be98ced092ea16b3d6bf1d51 Mon Sep 17 00:00:00 2001
From: jl777 <jameslee777@yahoo.com>
Date: Fri, 27 Apr 2018 15:13:20 +0300
Subject: [PATCH 3/3] Handle initial MoM

---
 iguana/dpow/dpow_fsm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c
index 844a9583c..b66bddcd0 100755
--- a/iguana/dpow/dpow_fsm.c
+++ b/iguana/dpow/dpow_fsm.c
@@ -237,9 +237,13 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu
     memset(MoM.bytes,0,sizeof(MoM));
     if ( (infojson= dpow_getinfo(myinfo,coin)) != 0 )
     {
-        if ( (prevMoMheight= jint(infojson,"prevMoMheight")) != 0 )
+        if ( (prevMoMheight= jint(infojson,"prevMoMheight")) >= 0 )
         {
+            if ( prevMoMheight == 0 )
+                prevMoMheight = 1;
             *MoMdepthp = (height - prevMoMheight);
+            if ( *MoMdepthp > 1440*30 )
+                *MoMdepthp = 1440*30;
             if ( *MoMdepthp > 0 && (MoMjson= issue_calcMoM(coin,height,*MoMdepthp)) != 0 )
             {
                 MoM = jbits256(MoMjson,"MoM");