]> Git Repo - VerusCoin.git/commitdiff
+prevMoMheight to getinfo
authorjl777 <[email protected]>
Thu, 26 Apr 2018 12:14:12 +0000 (15:14 +0300)
committerjl777 <[email protected]>
Thu, 26 Apr 2018 12:14:12 +0000 (15:14 +0300)
src/komodo_notary.h
src/rpcmisc.cpp

index 24e8500fd3549194c315d3c06aa1505eb1e4bb8c..55ec44e39a7425820287527aa81adb276dca70bf 100644 (file)
@@ -383,24 +383,23 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,
 }
 
 //struct komodo_state *komodo_stateptr(char *symbol,char *dest);
-int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp)
+
+struct notarized_checkpoint *komodo_npptr(int32_t height)
 {
-    char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;
+    char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0;
     if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
     {
-        *hashp = sp->NOTARIZED_HASH;
-        *txidp = sp->NOTARIZED_DESTTXID;
-        return(sp->NOTARIZED_HEIGHT);
-    }
-    else
-    {
-        memset(hashp,0,sizeof(*hashp));
-        memset(txidp,0,sizeof(*txidp));
-        return(0);
+        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 )
+                return(np);
+        }
     }
+    return(0);
 }
 
-struct notarized_checkpoint *komodo_npptr(int32_t height)
+int32_t komodo_prevMoMheight()
 {
     char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0;
     if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
@@ -408,13 +407,32 @@ 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 )
-                return(np);
+            if ( bits256_nonz(np->MoM) != 0 )
+                return(np->notarized_height);
         }
     }
     return(0);
 }
 
+int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp)
+{
+    char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;
+    if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
+    {
+        *hashp = sp->NOTARIZED_HASH;
+        *txidp = sp->NOTARIZED_DESTTXID;
+        *prevMoMheightp = komodo_prevMoMheight();
+        return(sp->NOTARIZED_HEIGHT);
+    }
+    else
+    {
+        *prevhtp = 0;
+        memset(hashp,0,sizeof(*hashp));
+        memset(txidp,0,sizeof(*txidp));
+        return(0);
+    }
+}
+
 int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
 {
     struct notarized_checkpoint *np = 0;
@@ -508,6 +526,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not
     np = &sp->NPOINTS[sp->NUM_NPOINTS++];
     memset(np,0,sizeof(*np));
     np->nHeight = nHeight;
+    sp->PREVNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT;
     sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height;
     sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
     sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
index c8b8a1aa67cf2b4684f7d07906aa8c8a824f4094..079354a7bf6a970a10489ec1133f416d6968b138 100644 (file)
@@ -46,7 +46,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr);
 int32_t Jumblr_secretaddradd(char *secretaddr);
 uint64_t komodo_interestsum();
 int32_t komodo_longestchain();
-int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp);
+int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp);
 uint32_t komodo_chainactive_timestamp();
 int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
 extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
@@ -61,7 +61,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS
 
 UniValue getinfo(const UniValue& params, bool fHelp)
 {
-    uint256 notarized_hash,notarized_desttxid; int32_t notarized_height,longestchain,kmdnotarized_height,txid_height;
+    uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height;
     if (fHelp || params.size() != 0)
         throw runtime_error(
             "getinfo\n"
@@ -97,7 +97,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
 
     proxyType proxy;
     GetProxy(NET_IPV4, proxy);
-    notarized_height = komodo_notarized_height(&notarized_hash,&notarized_desttxid);
+    notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);
     //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL));
 
     UniValue obj(UniValue::VOBJ);
@@ -105,6 +105,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
     obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
     obj.push_back(Pair("KMDversion", KOMODO_VERSION));
     obj.push_back(Pair("notarized", notarized_height));
+    obj.push_back(Pair("prevMoMheight", prevMoMheight));
     obj.push_back(Pair("notarizedhash", notarized_hash.ToString()));
     obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
     txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height);
This page took 0.031826 seconds and 4 git commands to generate.