diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 28e2779a3..d21f452c2 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -111,79 +111,55 @@ int32_t Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS; uint16_t Notaries_port = DPOW_SOCKPORT; char *Notaries_seeds[65]; -int32_t komodo_initjson2(char *fstr) +int32_t komodo_initjson(char *fname) { - char *field,*hexstr; cJSON *array,*item,*argjson; uint16_t port; int32_t i,n,num,retval = -1; - static portable_mutex_t notaries_mutex; static int32_t initflag; - if ( initflag == 0 ) + char *fstr,*field,*hexstr; cJSON *argjson,*array,*item; long fsize; uint16_t port; int32_t i,n,num,retval = -1; + if ( (fstr= OS_filestr(&fsize,fname)) != 0 ) { - portable_mutex_init(¬aries_mutex); - initflag = 1; - } - - portable_mutex_lock(¬aries_mutex); - if ( (argjson= cJSON_Parse(fstr)) != 0 ) - { - // memset arrays to 0! - memset(Notaries_seeds,0,sizeof(Notaries_seeds)); - memset(Notaries_elected,0,sizeof(Notaries_elected)); - - if ( (port= juint(argjson,"port")) != 0 ) - Notaries_port = port; - if ( (num= juint(argjson,"BTCminsigs")) > Notaries_BTCminsigs ) - Notaries_BTCminsigs = num; - Notaries_minsigs = juint(argjson,"minsigs"); - if ( (array= jarray(&n,argjson,"seeds")) != 0 && n <= 64 ) + if ( (argjson= cJSON_Parse(fstr)) != 0 ) { - for (i=0; i Notaries_BTCminsigs ) + Notaries_BTCminsigs = num; + Notaries_minsigs = juint(argjson,"minsigs"); + if ( (array= jarray(&n,argjson,"seeds")) != 0 && n <= 64 ) { - Notaries_seeds[i] = clonestr(jstri(array,i)); - //printf("%s ",Notaries_seeds[i]); + for (i=0; iFULLNODE < 0 ) { if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getiguanajson","")) != 0 ) { - //printf("NOTARIES retstr.%s\n", retstr); - if ( komodo_initjson2(retstr) < 0 ) - printf("init notaries failed!\n"); + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + portable_mutex_lock(¬aries_mutex); + Notaries_minsigs = juint(retjson,"minsigs"); + portable_mutex_unlock(¬aries_mutex); + if ( (array= jarray(&n,retjson,"notaries")) != 0 && n <= 64 ) + { + for (i=0; i 0 ) { for (i=0; i