nSPV mempool used by CC
This commit is contained in:
@@ -578,9 +578,13 @@ uint256 CCOraclesReverseScan(char const *logcategory,uint256 &txid,int32_t heigh
|
||||
return(zeroid);
|
||||
}
|
||||
|
||||
int32_t NSPV_coinaddr_inmempool(char const *logcategory,char *coinaddr,uint8_t CCflag);
|
||||
|
||||
int32_t myIs_coinaddr_inmempoolvout(char const *logcategory,char *coinaddr)
|
||||
{
|
||||
int32_t i,n; char destaddr[64];
|
||||
if ( KOMODO_NSPV != 0 )
|
||||
return(NSPV_coinaddr_inmempool(logcategory,coinaddr,1));
|
||||
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
|
||||
{
|
||||
const CTransaction &tx = e.GetTx();
|
||||
|
||||
@@ -16,14 +16,10 @@
|
||||
|
||||
// todo:
|
||||
|
||||
// use mempool functions in CC: myIsutxo_spentinmempool and mytxid_inmempool
|
||||
|
||||
// headers "sync" make sure it connects to prior blocks to notarization. use getinfo hdrht to get missing hdrs
|
||||
|
||||
// Myprivkey(uint8_t *privkey), scrub all destination privkey buffers
|
||||
// make sure to sanity check all vector lengths on receipt
|
||||
// make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database)
|
||||
// make req for utxo/txid more sane? (optional)
|
||||
// bug: under load, fullnode was returning all 0 nServices
|
||||
|
||||
#ifndef KOMODO_NSPV_H
|
||||
@@ -213,7 +209,7 @@ int32_t NSPV_rwmempoolresp(int32_t rwflag,uint8_t *serialized,struct NSPV_mempoo
|
||||
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vindex),&ptr->vindex);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
|
||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->funcid),&ptr->funcid);
|
||||
if ( rwflag != 0 )
|
||||
|
||||
@@ -101,7 +101,7 @@ struct NSPV_mempoolresp
|
||||
uint256 *txids;
|
||||
char coinaddr[64];
|
||||
uint256 txid;
|
||||
int32_t nodeheight,vout,pad32;
|
||||
int32_t nodeheight,vout,vindex;
|
||||
uint16_t numtxids; uint8_t CCflag,funcid;
|
||||
};
|
||||
|
||||
|
||||
@@ -241,9 +241,10 @@ int32_t NSPV_getaddresstxids(struct NSPV_txidsresp *ptr,char *coinaddr,bool isCC
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t NSPV_mempoolfuncs(std::vector<uint256> &txids,char *coinaddr,bool isCC,uint8_t funcid,uint256 txid,int32_t vout)
|
||||
int32_t NSPV_mempoolfuncs(int32_t *vindexp,std::vector<uint256> &txids,char *coinaddr,bool isCC,uint8_t funcid,uint256 txid,int32_t vout)
|
||||
{
|
||||
int32_t num = 0,vini = 0; char destaddr[64];
|
||||
int32_t num = 0,vini = 0,vouti = 0; char destaddr[64];
|
||||
*vindexp = -1;
|
||||
if ( mempool.size() == 0 )
|
||||
return(0);
|
||||
LOCK(mempool.cs);
|
||||
@@ -264,6 +265,7 @@ int32_t NSPV_mempoolfuncs(std::vector<uint256> &txids,char *coinaddr,bool isCC,u
|
||||
txids.push_back(hash);
|
||||
return(++num);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ( funcid == NSPV_MEMPOOL_ISSPENT )
|
||||
{
|
||||
@@ -273,6 +275,7 @@ int32_t NSPV_mempoolfuncs(std::vector<uint256> &txids,char *coinaddr,bool isCC,u
|
||||
if ( txin.prevout.n == vout && txin.prevout.hash == txid )
|
||||
{
|
||||
txids.push_back(hash);
|
||||
*vindexp = vini;
|
||||
return(++num);
|
||||
}
|
||||
vini++;
|
||||
@@ -288,9 +291,11 @@ int32_t NSPV_mempoolfuncs(std::vector<uint256> &txids,char *coinaddr,bool isCC,u
|
||||
if ( strcmp(destaddr,coinaddr) == 0 )
|
||||
{
|
||||
txids.push_back(hash);
|
||||
*vindexp = vouti;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
vouti++;
|
||||
}
|
||||
}
|
||||
//fprintf(stderr,"are vins for %s\n",uint256_str(str,hash));
|
||||
@@ -307,7 +312,7 @@ int32_t NSPV_mempooltxids(struct NSPV_mempoolresp *ptr,char *coinaddr,bool isCC,
|
||||
ptr->txid = txid;
|
||||
ptr->vout = vout;
|
||||
ptr->funcid = funcid;
|
||||
if ( NSPV_mempoolfuncs(txids,coinaddr,isCC,funcid,txid,vout) >= 0 )
|
||||
if ( NSPV_mempoolfuncs(&ptr->vindex,txids,coinaddr,isCC,funcid,txid,vout) >= 0 )
|
||||
{
|
||||
if ( (ptr->numtxids= (int32_t)txids.size()) >= 0 )
|
||||
{
|
||||
|
||||
@@ -689,6 +689,35 @@ UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256
|
||||
return(result);
|
||||
}
|
||||
|
||||
int32_t NSPV_coinaddr_inmempool(char const *logcategory,char *coinaddr,uint8_t CCflag)
|
||||
{
|
||||
NSPV_mempooltxids(coinaddr,CCflag,NSPV_MEMPOOL_ADDRESS,zeroid,-1);
|
||||
if ( NSPV_mempoolresult.txids != 0 && NSPV_mempoolresult.numtxids >= 1 && NSPV_mempoolresult.txid == txid && NSPV_mempoolresult.CCflag == CCflag )
|
||||
{
|
||||
LogPrint(logcategory,"found (%s) vout in mempool\n",coinaddr);
|
||||
return(true);
|
||||
} else return(false);
|
||||
}
|
||||
|
||||
bool NSPV_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout)
|
||||
{
|
||||
NSPV_mempooltxids("",0,NSPV_MEMPOOL_ISSPENT,txid,vout);
|
||||
if ( NSPV_mempoolresult.txids != 0 && NSPV_mempoolresult.numtxids == 1 && NSPV_mempoolresult.txid == txid )
|
||||
{
|
||||
spenttxid = NSPV_mempoolresult.txids[0];
|
||||
spentvini = NSPV_mempoolresult.vindex;
|
||||
return(true);
|
||||
} else return(false);
|
||||
}
|
||||
|
||||
bool NSPV_inmempool(uint256 txid)
|
||||
{
|
||||
NSPV_mempooltxids("",0,NSPV_MEMPOOL_INMEMPOOL,txid,0);
|
||||
if ( NSPV_mempoolresult.txids != 0 && NSPV_mempoolresult.numtxids == 1 && NSPV_mempoolresult.txids[0] == txid )
|
||||
return(true);
|
||||
else return(false);
|
||||
}
|
||||
|
||||
UniValue NSPV_notarizations(int32_t reqheight)
|
||||
{
|
||||
uint8_t msg[64]; int32_t i,iter,len = 0; struct NSPV_ntzsresp N,*ptr;
|
||||
|
||||
@@ -390,11 +390,14 @@ UniValue getdifficulty(const UniValue& params, bool fHelp)
|
||||
return GetNetworkDifficulty();
|
||||
}
|
||||
|
||||
bool NSPV_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout);
|
||||
bool NSPV_inmempool(uint256 txid);
|
||||
|
||||
bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout)
|
||||
{
|
||||
//char *uint256_str(char *str,uint256); char str[65];
|
||||
//LOCK(mempool.cs);
|
||||
int32_t vini = 0;
|
||||
if ( KOMODO_NSPV != 0 )
|
||||
return(NSPV_spentinmempool(spenttxid,spentvini,txid,vout));
|
||||
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
|
||||
{
|
||||
const CTransaction &tx = e.GetTx();
|
||||
@@ -417,6 +420,10 @@ bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,
|
||||
|
||||
bool mytxid_inmempool(uint256 txid)
|
||||
{
|
||||
if ( KOMODO_NSPV != 0 )
|
||||
{
|
||||
|
||||
}
|
||||
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
|
||||
{
|
||||
const CTransaction &tx = e.GetTx();
|
||||
|
||||
Reference in New Issue
Block a user