Browse Source

Merge pull request #792 from jl777/jl777

Jl777
patch-3
jl777 7 years ago
committed by GitHub
parent
commit
143d106136
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk_bitcoin.c
  3. 1279
      deprecated/iguana_notary.c
  4. 5
      iguana/dPoW.h
  5. 228
      iguana/dpow/dPoW.h
  6. 6
      iguana/dpow/dpow_fsm.c
  7. 4
      iguana/dpow/dpow_network.c
  8. 11
      iguana/dpow/dpow_rpc.c
  9. 85
      iguana/elected
  10. 1
      iguana/elected.2017
  11. 2
      iguana/iguana777.h
  12. 71
      iguana/iguana_notary.c
  13. 2
      includes/iguana_apideclares.h

6
basilisk/basilisk.c

@ -947,17 +947,17 @@ void basilisks_loop(void *arg)
//fprintf(stderr,"E ");
if ( myinfo->numdpows == 1 )
{
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
iguana_dPoWupdate(myinfo,myinfo->DPOWS[0]);
endmilli = startmilli + 100;
}
else if ( myinfo->numdpows > 1 )
{
dp = &myinfo->DPOWS[counter % myinfo->numdpows];
dp = myinfo->DPOWS[counter % myinfo->numdpows];
iguana_dPoWupdate(myinfo,dp);
//if ( (counter % myinfo->numdpows) != 0 )
{
//fprintf(stderr,"F ");
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
iguana_dPoWupdate(myinfo,myinfo->DPOWS[0]);
}
endmilli = startmilli + 30;
}

2
basilisk/basilisk_bitcoin.c

@ -609,7 +609,7 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi
{
if ( *completedp != 0 )
{
printf("splitfunds signedtx.(%s)\n",signedtx);
printf("splitfunds %s signedtx.(%s)\n",coin->symbol,signedtx);
if ( sendflag != 0 )
iguana_sendrawtransaction(myinfo,coin,signedtx);
free(rawtx);

1279
deprecated/iguana_notary.c

File diff suppressed because it is too large

5
iguana/dPoW.h

@ -16,10 +16,11 @@
#ifndef INCLUDE_DPOW_H
#define INCLUDE_DPOW_H
#define DPOW_MAXMOMDEPTH (1440 * 7)
//#define DPOW_MAXMOMDEPTH (1440 * 7)
#define DPOW_FIRSTRATIFY 1000
#define DPOW_MAXFREQ 100
#define DPOW_CHECKPOINTFREQ 10
#define DPOW_MINSIGS 13
#define DPOW_MIN_ASSETCHAIN_SIGS 11
@ -137,7 +138,7 @@ struct dpow_info
struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE];
bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying,minsigs,freq;
struct pax_transaction *PAX;
portable_mutex_t paxmutex,dexmutex;
uint32_t ipbits[128],numipbits;

228
iguana/dpow/dPoW.h

@ -1,228 +0,0 @@
/******************************************************************************
* Copyright © 2014-2018 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#ifndef INCLUDE_DPOW_H
#define INCLUDE_DPOW_H
#define DPOW_MAXMOMDEPTH (1440)
#define DPOW_FIRSTRATIFY 1000
#define DPOW_CHECKPOINTFREQ 10
#define DPOW_MINSIGS 13
#define DPOW_MIN_ASSETCHAIN_SIGS 11
//#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1)
#define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries)
#define DPOW_VERSION 0x1782
#define DPOW_UTXOSIZE 10000//50000
#define DPOW_MINOUTPUT 6000
#define DPOW_DURATION 600
#define DPOW_RATIFYDURATION (3600 * 24)
//#define DPOW_ENTRIESCHANNEL ('e' | ('n' << 8) | ('t' << 16) | ('r' << 24))
//#define DPOW_BTCENTRIESCHANNEL (~DPOW_ENTRIESCHANNEL)
//#define DPOW_UTXOCHANNEL ('d' | ('P' << 8) | ('o' << 16) | ('W' << 24))
#define DPOW_SIGCHANNEL ('s' | ('i' << 8) | ('g' << 16) | ('s' << 24))
#define DPOW_SIGBTCCHANNEL (~DPOW_SIGCHANNEL)
#define DPOW_TXIDCHANNEL ('t' | ('x' << 8) | ('i' << 16) | ('d' << 24))
#define DPOW_BTCTXIDCHANNEL (~DPOW_TXIDCHANNEL)
#define DPOW_FIFOSIZE 64
#define DPOW_MAXTX 8192
#define DPOW_THIRDPARTY_CONFIRMS 0
#define DPOW_KOMODOCONFIRMS 10
#define DPOW_BTCCONFIRMS 1
#define DPOW_MAXRELAYS 64
#define DPOW_MAXSIGLEN 128
#define DEX_VERSION 0x0105
#define DPOW_SOCKPORT 7775
#define DEX_SOCK 7774
#define PUB_SOCK 7773
#define REP_SOCK 7772
#define DPOW_EPOCHDURATION 600
struct dpow_coinentry
{
bits256 prev_hash;
uint8_t siglens[DPOW_MAXRELAYS],sigs[DPOW_MAXRELAYS][DPOW_MAXSIGLEN];
int32_t prev_vout;
};
struct dpow_utxoentry
{
bits256 srchash,desthash,commit,hashmsg;
uint64_t recvmask,othermasks[DPOW_MAXRELAYS];
int32_t srcvout,destvout,height;
int8_t bestk; uint8_t pubkey[33];
};
struct dpow_entry
{
bits256 commit,beacon,ratifysrcutxo,ratifydestutxo;
uint64_t masks[2][DPOW_MAXRELAYS],recvmask,othermask,bestmask,ratifyrecvmask,ratifybestmask;
int32_t height; uint32_t pendingcrcs[2],paxwdcrc;
uint16_t ratifysrcvout,ratifydestvout;
int8_t bestk,ratifybestk;
uint8_t pubkey[33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2];
struct dpow_coinentry src,dest;
};
struct dpow_sigentry
{
bits256 beacon;
uint64_t mask;
int32_t refcount;
uint8_t senderind,lastk,siglen,sig[DPOW_MAXSIGLEN],senderpub[33];
};
struct komodo_notaries
{
struct basilisk_relay RELAYS[DPOW_MAXRELAYS];
int32_t NUMRELAYS,RELAYID;
};
struct dpow_hashheight { bits256 hash; int32_t height; };
struct dpow_checkpoint
{
struct dpow_hashheight blockhash,approved;
bits256 miner; uint32_t blocktime,timestamp;
};
struct dpow_block
{
bits256 hashmsg,desttxid,srctxid,beacon,commit,MoM;
struct iguana_info *srccoin,*destcoin; char *opret_symbol;
uint64_t destsigsmasks[DPOW_MAXRELAYS],srcsigsmasks[DPOW_MAXRELAYS];
uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2];
struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc;
int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS];
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk;
cJSON *ratified;
uint8_t ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2];
char handles[DPOW_MAXRELAYS][32];
char signedtx[32768]; uint8_t ratifyrawtx[2][32768]; uint32_t pendingcrcs[2];
};
struct pax_transaction
{
UT_hash_handle hh;
bits256 txid;
uint64_t komodoshis,fiatoshis;
int32_t marked,height,kmdheight;
uint16_t vout;
char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag;
};
struct dpow_info
{
char symbol[16],dest[16]; uint8_t minerkey33[33],minerid; uint64_t lastrecvmask;
struct dpow_checkpoint checkpoint,last,destchaintip,srcfifo[DPOW_FIFOSIZE],destfifo[DPOW_FIFOSIZE];
struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE];
bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying;
struct pax_transaction *PAX;
portable_mutex_t paxmutex,dexmutex;
uint32_t ipbits[128],numipbits;
struct dpow_block **blocks;
};
struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; };
struct komodo_ccdataMoMoM
{
bits256 MoMoM;
int32_t kmdstarti,kmdendi,MoMoMdepth,numpairs,len;
struct komodo_ccdatapair *pairs;
};
uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp);
int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,int32_t src_or_dest,struct dpow_block *bp);
void dex_updateclient(struct supernet_info *myinfo);
char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen,int32_t M,char *field);
char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration);
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *merklerootp,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin);
void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen);
int32_t dpow_nanomsg_update(struct supernet_info *myinfo);
int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr,char *srccoin);
void komodo_assetcoins(int32_t fullnode,uint64_t mask);
int32_t iguana_isnotarychain(char *symbol);
cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin);
cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid);
cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash);
bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height);
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin);
char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin);
cJSON *dpow_kvupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *key,char *value,int32_t flags);
cJSON *dpow_kvsearch(struct supernet_info *myinfo,struct iguana_info *coin,char *key);
void init_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin);
cJSON *dpow_getmessage(struct supernet_info *myinfo,char *jsonstr);
cJSON *dpow_addmessage(struct supernet_info *myinfo,char *jsonstr);
cJSON *dpow_psock(struct supernet_info *myinfo,char *jsonstr);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2);
char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height);
char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol);
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx);
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout);
char *_dex_gettxin(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout);
char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_getmessage(struct supernet_info *myinfo,char *jsonstr);
char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listunspent2(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listspent(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_getbalance(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *coinaddr,int32_t count,int32_t skip);
char *_dex_listtransactions2(struct supernet_info *myinfo,char *symbol,char *coinaddr,int32_t count,int32_t skip);
char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol);
int32_t _dex_getheight(struct supernet_info *myinfo,char *symbol);
char *_dex_getnotaries(struct supernet_info *myinfo,char *symbol);
char *_dex_kvupdate(struct supernet_info *myinfo,char *symbol,char *key,char *value,int32_t flags);
char *_dex_kvsearch(struct supernet_info *myinfo,char *symbol,char *key);
char *_dex_psock(struct supernet_info *myinfo,char *jsonstr);
int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height);
cJSON *dpow_checkaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
void dex_channelsend(struct supernet_info *myinfo,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen);
void kmd_bitcoinscan();
cJSON *kmd_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
struct iguana_info *iguana_coinfind(char *symbol);
cJSON *kmd_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
cJSON *kmd_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *kmd_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *kmd_gettxin(struct iguana_info *coin,bits256 txid,int32_t vout);
cJSON *dpow_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_gettxin(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
#endif

6
iguana/dpow/dpow_fsm.c

@ -242,6 +242,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu
if ( prevMoMheight == 0 )
prevMoMheight = 1;
*MoMdepthp = (height - prevMoMheight);
//printf("%s ht.%d prevMoM.%d -> depth %d\n",coin->symbol,height,prevMoMheight,*MoMdepthp);
if ( *MoMdepthp > 1440*30 )
*MoMdepthp = 1440*30;
if ( *MoMdepthp > 0 && (MoMjson= issue_calcMoM(coin,height,*MoMdepthp)) != 0 )
@ -419,6 +420,7 @@ void dpow_statemachinestart(void *ptr)
printf(" statemachinestart this node %s %s is not official notary numnotaries.%d kmdht.%d bpht.%d\n",srcaddr,destaddr,bp->numnotaries,kmdheight,bp->height);
free(ptr);
dp->ratifying -= bp->isratify;
exit(-1);
return;
}
printf("myind.%d\n",myind);
@ -509,7 +511,7 @@ void dpow_statemachinestart(void *ptr)
extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp);
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
}
printf("PAXWDCRC.%x myind.%d isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u+dur.%d vs %ld\n",bp->paxwdcrc,bp->myind,bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),starttime,bp->duration,time(NULL));
printf("PAXWDCRC.%x myind.%d isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u+dur.%d vs %ld MoM[%d] %s\n",bp->paxwdcrc,bp->myind,bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),starttime,bp->duration,time(NULL),bp->MoMdepth,bits256_str(str2,bp->MoM));
for (i=0; i<sizeof(srchash); i++)
srchash.bytes[i] = dp->minerkey33[i+1];
//printf("start utxosync start.%u %u\n",starttime,(uint32_t)time(NULL));
@ -519,7 +521,7 @@ void dpow_statemachinestart(void *ptr)
{
if ( bp->isratify == 0 )
{
if ( myinfo->DPOWS[0].ratifying != 0 )
if ( myinfo->DPOWS[0]->ratifying != 0 )
{
printf("break due to already ratifying\n");
break;

4
iguana/dpow/dpow_network.c

@ -2066,9 +2066,9 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
dp = 0;
for (i=0; i<myinfo->numdpows; i++)
{
if ( strcmp(np->symbol,myinfo->DPOWS[i].symbol) == 0 )
if ( strcmp(np->symbol,myinfo->DPOWS[i]->symbol) == 0 )
{
dp = &myinfo->DPOWS[i];
dp = myinfo->DPOWS[i];
break;
}
}

11
iguana/dpow/dpow_rpc.c

@ -72,16 +72,18 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
}
char *Notaries_elected[65][2];
char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" };
int32_t Notaries_numseeds = (int32_t)(sizeof(seeds)/sizeof(*seeds)),Notaries_num,Notaries_BTCminsigs = DPOW_MINSIGS,Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS;
//char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" };
int32_t Notaries_numseeds;// = (int32_t)(sizeof(seeds)/sizeof(*seeds))
int32_t Notaries_num,Notaries_BTCminsigs = DPOW_MINSIGS;
int32_t Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS;
uint16_t Notaries_port = DPOW_SOCKPORT;
char *Notaries_seeds[65];
int32_t komodo_initjson(char *fname)
{
char *fstr,*field,*hexstr; cJSON *argjson,*array,*item; long fsize; uint16_t port; int32_t i,n,num,retval = -1;
for (i=0; i<Notaries_numseeds; i++)
Notaries_seeds[i] = seeds[i];
//for (i=0; i<Notaries_numseeds; i++)
// Notaries_seeds[i] = seeds[i];
if ( (fstr= OS_filestr(&fsize,fname)) != 0 )
{
if ( (argjson= cJSON_Parse(fstr)) != 0 )
@ -99,6 +101,7 @@ int32_t komodo_initjson(char *fname)
Notaries_seeds[i] = clonestr(jstri(array,i));
printf("%s ",Notaries_seeds[i]);
}
Notaries_numseeds = i;
printf("Notaries_numseeds.%d\n",Notaries_numseeds);
}
if ( (array= jarray(&n,argjson,"notaries")) != 0 && n <= 64 )

85
iguana/elected

File diff suppressed because one or more lines are too long

1
iguana/elected.2017

File diff suppressed because one or more lines are too long

2
iguana/iguana777.h

@ -167,7 +167,7 @@ struct supernet_info
uint8_t *pingbuf;
struct basilisk_request DEXaccept;
FILE *dexfp;
struct dpow_info DPOWS[1024]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
struct dpow_info *DPOWS[8192]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
struct delayedPoW_info dPoW;
struct basilisk_spend *spends; int32_t numspends;
char bindaddr[64];

71
iguana/iguana_notary.c

@ -61,10 +61,10 @@ 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; 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;
void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t 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 )
/*if ( strcmp("BTC",dp->dest) == 0 )
{
freq = DPOW_CHECKPOINTFREQ;
minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
@ -72,10 +72,10 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
else
{
minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( strcmp("CHIPS",dp->symbol) == 0 )
freq = 100;
if ( strcmp("CHIPS",dp->symbol) == 0 || strncmp("TEST",dp->symbol,4) == 0)
freq = DPOW_MAXFREQ;
else freq = 1;
}
}*/
dpow_fifoupdate(myinfo,dp->srcfifo,dp->last);
/*if ( strcmp(dp->dest,"KMD") == 0 )//|| strcmp(dp->dest,"CHAIN") == 0 )
{
@ -119,15 +119,17 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
} else return;
} else return;
}*/
if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % freq) == 0 )
if ( dp->freq <= 0 )
dp->freq = 1;
if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % dp->freq) == 0 )
{
if ( (0) && strcmp("KMD",dp->symbol) == 0 )
printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs);
printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d freq.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),dp->minsigs,dp->freq);
dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000);
ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t));
ptrs[0] = (void *)myinfo;
ptrs[1] = (void *)dp;
ptrs[2] = (void *)(uint64_t)minsigs;
ptrs[2] = (void *)(uint64_t)dp->minsigs;
if ( strcmp(dp->dest,"KMD") != 0 )
ptrs[3] = (void *)DPOW_DURATION;
else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains
@ -138,13 +140,13 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
if ( OS_thread_create((void *)((uint64_t)&ptrs[5] + sizeof(struct dpow_checkpoint)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )
{
}
if ( ht > 500 )
if ( ht > DPOW_MAXFREQ*5 )
{
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 )
printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks);
for (i=ht-500; i>ht-10000&&i>100; i--)
for (i=ht-DPOW_MAXFREQ*5; i>ht-DPOW_MAXFREQ*100&&i>DPOW_MAXFREQ; i--)
{
if ( (i % 100) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff )
if ( (i % DPOW_MAXFREQ) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff )
{
dp->blocks[i] = 0;
Numallocated--;
@ -293,9 +295,14 @@ void dpow_addresses()
#include "../includes/iguana_apideclares.h"
#include "../includes/iguana_apideclares2.h"
THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq)
{
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*destcoin; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows];
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*destcoin; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp;
if ( (dp= myinfo->DPOWS[myinfo->numdpows]) == 0 )
myinfo->DPOWS[myinfo->numdpows] = calloc(1,sizeof(*dp));
if ( (dp= myinfo->DPOWS[myinfo->numdpows]) == 0 )
return(clonestr("{\"error\":\"dPoW cant allocate memory\"}"));
memset(dp,0,sizeof(*dp));
destvalid = srcvalid = 0;
if ( myinfo->NOTARY.RELAYID < 0 )
{
@ -330,7 +337,7 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
if ( myinfo->numdpows > 1 )
{
for (i=1; i<myinfo->numdpows; i++)
if ( strcmp(symbol,myinfo->DPOWS[i].symbol) == 0 )
if ( strcmp(symbol,myinfo->DPOWS[i]->symbol) == 0 )
{
dp->symbol[0] = 0;
return(clonestr("{\"error\":\"cant dPoW same coin again\"}"));
@ -349,6 +356,20 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
}
if ( dp->srcconfirms > DPOW_FIFOSIZE )
dp->srcconfirms = DPOW_FIFOSIZE;
if ( strcmp("BTC",dp->dest) == 0 )
{
dp->freq = DPOW_CHECKPOINTFREQ;
dp->minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
}
else
{
dp->minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( strcmp("CHIPS",dp->symbol) == 0 || strncmp("TEST",dp->symbol,4) == 0)
dp->freq = DPOW_MAXFREQ;
else if ( freq >= 2 )
dp->freq = freq;
else dp->freq = 1;
}
src = iguana_coinfind(dp->symbol);
destcoin = iguana_coinfind(dp->dest);
if ( src == 0 || destcoin == 0 )
@ -379,9 +400,6 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
free(retstr);
retstr = 0;
}
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid);
if ( srcvalid <= 0 || destvalid <= 0 )
{
dp->symbol[0] = 0;
@ -394,7 +412,7 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
}
if ( dp->blocks == 0 )
{
dp->maxblocks = 1000000;
dp->maxblocks = 10000;
dp->blocks = calloc(dp->maxblocks,sizeof(*dp->blocks));
}
portable_mutex_init(&dp->paxmutex);
@ -404,6 +422,9 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
//uint8_t buf[32768];
//dpow_paxpending(buf);
myinfo->numdpows++;
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d, num.%d freq.%d minsigs.%d\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid,myinfo->numdpows,dp->freq,dp->minsigs);
return(clonestr("{\"result\":\"success\"}"));
}
@ -467,7 +488,7 @@ STRING_ARG(dpow,pending,fiat)
base[i] = 0;
for (i=0; i<myinfo->numdpows; i++)
{
dp = &myinfo->DPOWS[i];
dp = myinfo->DPOWS[i];
if ( strcmp(dp->symbol,base) == 0 )
return(jprint(dpow_withdraws_pending(dp),1));
}
@ -847,7 +868,7 @@ STRING_ARG(dpow,active,maskhex)
n = komodo_notaries("KMD",pubkeys,current);
if ( maskhex == 0 || maskhex[0] == 0 )
{
mask = myinfo->DPOWS[0].lastrecvmask;
mask = myinfo->DPOWS[0]->lastrecvmask;
for (i=0; i<n; i++)
{
if ( ((1LL << i) & mask) != 0 )
@ -888,7 +909,7 @@ STRING_ARG(dpow,active,maskhex)
ZERO_ARGS(dpow,cancelratify)
{
myinfo->DPOWS[0].cancelratify = 1;
myinfo->DPOWS[0]->cancelratify = 1;
return(clonestr("{\"result\":\"queued dpow cancel ratify\"}"));
}
@ -903,18 +924,18 @@ TWOINTS_AND_ARRAY(dpow,ratify,minsigs,timestamp,ratified)
ptrs[0] = (void *)myinfo;
if ( (source= jstr(json,"source")) == 0 )
source = "KMD";
ptrs[1] = (void *)&myinfo->DPOWS[0];
ptrs[1] = (void *)myinfo->DPOWS[0];
for (i=0; i<myinfo->numdpows; i++)
if ( strcmp(myinfo->DPOWS[0].symbol,source) == 0 )
if ( strcmp(myinfo->DPOWS[0]->symbol,source) == 0 )
{
ptrs[1] = (void *)&myinfo->DPOWS[i];
ptrs[1] = (void *)myinfo->DPOWS[i];
break;
}
ptrs[2] = (void *)(long)minsigs;
ptrs[3] = (void *)DPOW_RATIFYDURATION;
ptrs[4] = (void *)jprint(ratified,0);
memcpy(&ptrs[5],&checkpoint,sizeof(checkpoint));
myinfo->DPOWS[0].cancelratify = 0;
myinfo->DPOWS[0]->cancelratify = 0;
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )
{
}

2
includes/iguana_apideclares.h

@ -174,7 +174,7 @@ STRING_AND_INT(iguana,snapshot,symbol,height);
INT_ARRAY_STRING(iguana,dividends,height,vals,symbol);
THREE_STRINGS(iguana,passthru,asset,function,hex);
STRING_ARG(iguana,initfastfind,activecoin);
THREE_STRINGS(iguana,dpow,symbol,dest,pubkey);
THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq);
STRING_ARG(iguana,peers,activecoin);
STRING_AND_INT(iguana,maxpeers,activecoin,max);
STRING_ARG(iguana,getconnectioncount,activecoin);

Loading…
Cancel
Save