diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 1d0ae871b..4070c3567 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -324,3 +324,64 @@ void dpow_sigsend(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_ len = dpow_rwsigentry(1,data,&dsig); dpow_send(myinfo,dp,bp,srchash,bp->hashmsg,sigchannel,bp->height,data,len,bp->sigcrcs); } + +uint32_t komodo_assetmagic(char *symbol,uint64_t supply) +{ + uint8_t buf[512]; int32_t len = 0; + len = iguana_rwnum(1,&buf[len],sizeof(supply),(void *)&supply); + strcpy((char *)&buf[len],symbol); + len += strlen(symbol); + return(calc_crc32(0,buf,len)); +} + +int32_t komodo_shortflag(char *symbol) +{ + int32_t i,shortflag = 0; + if ( symbol[0] == '-' ) + { + shortflag = 1; + for (i=0; symbol[i+1]!=0; i++) + symbol[i] = symbol[i+1]; + symbol[i] = 0; + } + return(shortflag); +} + +uint16_t komodo_assetport(uint32_t magic,int32_t shortflag) +{ + return(8000 + shortflag*7777 + (magic % 7777)); +} + +uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,int32_t *shortflagp) +{ + *magicp = komodo_assetmagic(symbol,supply); + *shortflagp = komodo_shortflag(symbol); + return(komodo_assetport(*magicp,*shortflagp)); +} + +#define MAX_CURRENCIES 32 +extern char CURRENCIES[][8]; + +void komodo_assetcoins() +{ + int32_t i,j,shortflag; uint32_t magic; cJSON *json; uint16_t port; char jsonstr[512],magicstr[9]; struct iguana_info *coin; + for (i=0; isymbolcrc = symbolcrc = calc_crc32(0,symbol,(int32_t)strlen(symbol)); //portable_mutex_lock(&myinfo->allcoins_mutex); coin->coinid = myinfo->totalcoins++; - HASH_ADD(hh,myinfo->allcoins,symbolcrc,sizeof(coin->symbolcrc),coin); + HASH_ADD(hh,myinfo->allcoins,symbolcrc,sizeof(coin->symbolcrc),coin); //portable_mutex_unlock(&myinfo->allcoins_mutex); struct iguana_info *virt,*tmp; HASH_ITER(hh,myinfo->allcoins,virt,tmp) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index d81afafe4..5a48378d3 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -197,6 +197,8 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey) return(clonestr("{\"error\":\"need 33 byte pubkey\"}")); if ( symbol == 0 || symbol[0] == 0 ) symbol = "KMD"; + if ( myinfo->numdpows == 1 ) + komodo_assetcoins(); if ( iguana_coinfind(symbol) == 0 ) return(clonestr("{\"error\":\"cant dPoW an inactive coin\"}")); if ( strcmp(symbol,"KMD") == 0 && iguana_coinfind("BTC") == 0 )