}
//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 )
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;
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;
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;
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"
proxyType proxy;
GetProxy(NET_IPV4, proxy);
- notarized_height = komodo_notarized_height(¬arized_hash,¬arized_desttxid);
+ notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid);
//fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL));
UniValue obj(UniValue::VOBJ);
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);