From aec18840703dbea6a38bcaa98b3e34312308bd10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 14 Apr 2019 02:15:56 -1100 Subject: [PATCH] StartShutdown(); instead of exit() --- src/cc/dice.cpp | 2 +- src/cryptoconditions/src/secp256k1.c | 2 +- src/komodo_bitcoind.h | 4 ++-- src/komodo_gateway.h | 2 +- src/komodo_utils.h | 27 ++++++++++++++++----------- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 76d68e090..20f7a0567 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1662,7 +1662,7 @@ void *dealer0_loop(void *_arg) if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); - exit(-1); + StartShutdown(); } fprintf(stderr,"dealer0 node running\n"); height = lastht = 0; diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index 31bab06e5..aa82376a3 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -68,7 +68,7 @@ void lockSign() { } if (!secp256k1_context_randomize(ec_ctx_sign, ent)) { fprintf(stderr, "Could not randomize secp256k1 context\n"); - exit(1); + StartShutdown(); } } diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 58d984eb7..2f9c1a8d7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -57,7 +57,7 @@ void init_string(struct return_string *s) if ( s->ptr == NULL ) { fprintf(stderr,"init_string malloc() failed\n"); - exit(-1); + StartShutdown(); } s->ptr[0] = '\0'; } @@ -94,7 +94,7 @@ size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string * if ( s->ptr == NULL ) { fprintf(stderr, "accumulate realloc() failed\n"); - exit(-1); + StartShutdown(); } memcpy(s->ptr+s->len,ptr,size*nmemb); s->ptr[new_len] = '\0'; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b1860dbc1..a6b5b4566 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -653,7 +653,7 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max) if ( sizeof(banned_txids)/sizeof(*banned_txids) > max ) { fprintf(stderr,"komodo_bannedset: buffer too small %ld vs %d\n",sizeof(banned_txids)/sizeof(*banned_txids),max); - exit(-1); + StartShutdown(); } for (i=0; i (uint64_t)90*1000*1000000 ) { fprintf(stderr,"-ac_supply must be less than 90 billion\n"); - exit(0); + StartShutdown(); } fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY); @@ -1839,7 +1839,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_FOUNDERS_REWARD != 0 ) { fprintf(stderr,"cannot use founders reward and commission on the same chain.\n"); - exit(0); + StartShutdown(); } if ( ASSETCHAINS_CC != 0 ) { @@ -1879,7 +1879,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 ) { fprintf(stderr,"can only have one of -ac_beam or -ac_coda\n"); - exit(0); + StartShutdown(); } ASSETCHAINS_SELFIMPORT = GetArg("-ac_import",""); // BEAM, CODA, PUBKEY, GATEWAY if ( ASSETCHAINS_SELFIMPORT == "PUBKEY" ) @@ -1887,18 +1887,18 @@ void komodo_args(char *argv0) if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 ) { fprintf(stderr,"invalid -ac_pubkey for -ac_import=PUBKEY\n"); - exit(0); + StartShutdown(); } } else if ( ASSETCHAINS_SELFIMPORT == "BEAM" && ASSETCHAINS_BEAMPORT == 0 ) { fprintf(stderr,"missing -ac_beam for BEAM rpcport\n"); - exit(0); + StartShutdown(); } else if ( ASSETCHAINS_SELFIMPORT == "CODA" && ASSETCHAINS_CODAPORT == 0 ) { fprintf(stderr,"missing -ac_coda for CODA rpcport\n"); - exit(0); + StartShutdown(); } // else it can be gateway coin @@ -1926,12 +1926,12 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_SUPPLY > 10000000000 ) { printf("ac_pubkey or ac_script wont work with ac_supply over 10 billion\n"); - exit(0); + StartShutdown(); } if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) { printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n"); - exit(0); + StartShutdown(); } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) { @@ -1972,7 +1972,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 && ASSETCHAINS_MARMARA != 0 ) { fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n"); - exit(0); + StartShutdown(); } if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY[0] != 0 || ASSETCHAINS_BLOCKTIME != 60 || ASSETCHAINS_CBOPRET != 0 || Mineropret.size() != 0 ) { @@ -2150,7 +2150,7 @@ void komodo_args(char *argv0) if ( strcmp(ASSETCHAINS_SYMBOL,"KMD") == 0 ) { fprintf(stderr,"cant have assetchain named KMD\n"); - exit(0); + StartShutdown(); } if ( (port= komodo_userpass(ASSETCHAINS_USERPASS,ASSETCHAINS_SYMBOL)) != 0 ) ASSETCHAINS_RPCPORT = port; @@ -2232,6 +2232,11 @@ void komodo_args(char *argv0) } else if ( strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 ) dpowconfs = 0; + else if ( ASSETCHAINS_PRIVATE != 0 ) + { + fprintf(stderr,"-ac_private for a non-PIRATE chain is not supported. The only reason to have an -ac_private chain is for total privacy and that is best achieved with the largest anon set. PIRATE has that and it is recommended to just use PIRATE\n"); + StartShutdown(); + } } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs); if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"SUPERNET") == 0 || strcmp(ASSETCHAINS_SYMBOL,"DEX") == 0 || strcmp(ASSETCHAINS_SYMBOL,"COQUI") == 0 || strcmp(ASSETCHAINS_SYMBOL,"PIRATE") == 0 || strcmp(ASSETCHAINS_SYMBOL,"KMDICE") == 0 )