Fix spamming
This commit is contained in:
@@ -77,7 +77,8 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
|||||||
//fprintf(stderr,"call passport iteration\n");
|
//fprintf(stderr,"call passport iteration\n");
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
{
|
{
|
||||||
komodo_passport_iteration();
|
if ( KOMODO_NSPV == 0 )
|
||||||
|
komodo_passport_iteration();
|
||||||
for (i=0; i<10; i++)
|
for (i=0; i<10; i++)
|
||||||
{
|
{
|
||||||
fShutdown = ShutdownRequested();
|
fShutdown = ShutdownRequested();
|
||||||
|
|||||||
@@ -256,26 +256,6 @@ void NSPV_txproof_purge(struct NSPV_txproof *ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*struct NSPV_utxo
|
|
||||||
{
|
|
||||||
struct NSPV_txproof T;
|
|
||||||
int64_t satoshis,extradata;
|
|
||||||
int32_t vout,prevht,nextht,pad32;
|
|
||||||
};
|
|
||||||
|
|
||||||
int32_t NSPV_rwutxo(int32_t rwflag,uint8_t *serialized,struct NSPV_utxo *ptr)
|
|
||||||
{
|
|
||||||
int32_t len = 0;
|
|
||||||
len += NSPV_rwtxproof(rwflag,&serialized[len],&ptr->T);
|
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis);
|
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->extradata),&ptr->extradata);
|
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
|
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevht),&ptr->prevht);
|
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nextht),&ptr->nextht);
|
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32);
|
|
||||||
return(len);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
struct NSPV_ntzproofshared
|
struct NSPV_ntzproofshared
|
||||||
{
|
{
|
||||||
struct NSPV_equihdr *hdrs;
|
struct NSPV_equihdr *hdrs;
|
||||||
@@ -383,4 +363,13 @@ void NSPV_broadcast_purge(struct NSPV_broadcastresp *ptr)
|
|||||||
memset(ptr,0,sizeof(*ptr));
|
memset(ptr,0,sizeof(*ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256 NSPV_doublesha256(uint8_t *data,int32_t datalen)
|
||||||
|
{
|
||||||
|
bits256 _hash; uint256 hash;
|
||||||
|
_hash = bits256_doublesha256(0,data,datalen);
|
||||||
|
for (i=0; i<32; i++)
|
||||||
|
((uint8_t *)&hash)[i] = _hash.bytes[31 - i];
|
||||||
|
return(hash);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // KOMODO_NSPV_H
|
#endif // KOMODO_NSPV_H
|
||||||
|
|||||||
@@ -384,13 +384,11 @@ UniValue NSPV_spentinfo(uint256 txid,int32_t vout)
|
|||||||
|
|
||||||
UniValue NSPV_broadcast(char *hex)
|
UniValue NSPV_broadcast(char *hex)
|
||||||
{
|
{
|
||||||
uint8_t *msg,*data; bits256 _txid; uint256 txid; uint16_t n; int32_t i,len = 0; struct NSPV_broadcastresp B;
|
uint8_t *msg,*data; uint256 txid; uint16_t n; int32_t i,len = 0; struct NSPV_broadcastresp B;
|
||||||
n = (int32_t)strlen(hex) >> 1;
|
n = (int32_t)strlen(hex) >> 1;
|
||||||
data = (uint8_t *)malloc(n);
|
data = (uint8_t *)malloc(n);
|
||||||
decode_hex(data,n,hex);
|
decode_hex(data,n,hex);
|
||||||
_txid = bits256_doublesha256(0,data,n);
|
txid = NSPV_doublesha256(data,n);
|
||||||
for (i=0; i<32; i++)
|
|
||||||
((uint8_t *)&txid)[i] = _txid.bytes[31 - i];
|
|
||||||
msg = (uint8_t *)malloc(1 + sizeof(txid) + sizeof(n) + n);
|
msg = (uint8_t *)malloc(1 + sizeof(txid) + sizeof(n) + n);
|
||||||
msg[len++] = NSPV_BROADCAST;
|
msg[len++] = NSPV_BROADCAST;
|
||||||
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
|
||||||
|
|||||||
@@ -23,6 +23,37 @@ extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
|
|||||||
#define NSPV_AUTOLOGOUT 60
|
#define NSPV_AUTOLOGOUT 60
|
||||||
#define NSPV_BRANCHID 0x76b809bb
|
#define NSPV_BRANCHID 0x76b809bb
|
||||||
|
|
||||||
|
|
||||||
|
/*struct NSPV_ntzproofshared
|
||||||
|
{
|
||||||
|
struct NSPV_equihdr *hdrs;
|
||||||
|
int32_t prevht,nextht,pad32;
|
||||||
|
uint16_t numhdrs,pad16;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NSPV_ntzsproofresp
|
||||||
|
{
|
||||||
|
struct NSPV_ntzproofshared common;
|
||||||
|
uint256 prevtxid,nexttxid;
|
||||||
|
int32_t pad32,prevtxidht,nexttxidht;
|
||||||
|
uint16_t prevtxlen,nexttxlen;
|
||||||
|
uint8_t *prevntz,*nextntz;
|
||||||
|
};*/
|
||||||
|
|
||||||
|
int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresult *ptr)
|
||||||
|
{
|
||||||
|
int32_t i;
|
||||||
|
// verify nextntz is valid notarization
|
||||||
|
// validate blockhash of lasthdr with nextntz value, and height
|
||||||
|
for (i=numhdrs-1; i>0; i--)
|
||||||
|
{
|
||||||
|
// make sure the hash of i-1 matches the prevBlockhash of i
|
||||||
|
}
|
||||||
|
// verify prevntz is valid notarization
|
||||||
|
// verify blockhash of first hdr with prevntz value and height
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t NSPV_gettransaction(uint256 txid,int32_t height,CTransaction &tx)
|
int32_t NSPV_gettransaction(uint256 txid,int32_t height,CTransaction &tx)
|
||||||
{
|
{
|
||||||
char *txstr; int32_t retval = 0;
|
char *txstr; int32_t retval = 0;
|
||||||
@@ -35,11 +66,15 @@ int32_t NSPV_gettransaction(uint256 txid,int32_t height,CTransaction &tx)
|
|||||||
retval = -1;
|
retval = -1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf("got tx.(%s)\n",txstr);
|
|
||||||
// need to validate txproof
|
|
||||||
NSPV_notarizations(height); // gets the prev and next notarizations
|
NSPV_notarizations(height); // gets the prev and next notarizations
|
||||||
NSPV_hdrsproof(NSPV_ntzsresult.prevntz.height,NSPV_ntzsresult.nextntz.height); // validate the segment
|
if ( NSPV_ntzsresult.prevntz.height != 0 && NSPV_ntzsresult.prevntz.height <= NSPV_ntzsresult.nextntz.height )
|
||||||
// merkle prove txproof to the merkleroot in the corresponding hdr
|
{
|
||||||
|
NSPV_hdrsproof(NSPV_ntzsresult.prevntz.height,NSPV_ntzsresult.nextntz.height); // validate the segment
|
||||||
|
if ( NSPV_validatehdrs(&NSPV_ntzsproofresult) == 0 )
|
||||||
|
{
|
||||||
|
// merkle prove txproof to the merkleroot in the corresponding hdr
|
||||||
|
}
|
||||||
|
} else retval = -1;
|
||||||
}
|
}
|
||||||
free(txstr);
|
free(txstr);
|
||||||
return(retval);
|
return(retval);
|
||||||
|
|||||||
Reference in New Issue
Block a user