/*===========================================================================* * hgfs_cleanup * *===========================================================================*/ PUBLIC void hgfs_cleanup() { /* Clean up state. */ rpc_close(); }
static void purplemot_close(PurpleConnection *gc) { struct pm_account *account = gc->proto_data; rpc_close(account); }
void db_update_coinds(YAAMP_DB *db) { for(CLI li = g_list_coind.first; li; li = li->next) { YAAMP_COIND *coind = (YAAMP_COIND *)li->data; if(coind->deleted) continue; if(coind->auto_ready) continue; debuglog("disabling %s\n", coind->symbol); db_query(db, "update coins set auto_ready=%d where id=%d", coind->auto_ready, coind->id); } //////////////////////////////////////////////////////////////////////////////////////// db_query(db, "select id, name, rpchost, rpcport, rpcuser, rpcpasswd, rpcencoding, master_wallet, reward, price, "\ "hassubmitblock, txmessage, enable, auto_ready, algo, pool_ttf, charity_address, charity_amount, charity_percent, "\ "reward_mul, symbol, auxpow, actual_ttf, network_ttf, usememorypool "\ "from coins where enable and auto_ready and algo='%s' order by index_avg", g_stratum_algo); MYSQL_RES *result = mysql_store_result(&db->mysql); if(!result) yaamp_error("Cant query database"); MYSQL_ROW row; g_list_coind.Enter(); while((row = mysql_fetch_row(result)) != NULL) { YAAMP_COIND *coind = (YAAMP_COIND *)object_find(&g_list_coind, atoi(row[0])); if(!coind) { coind = new YAAMP_COIND; memset(coind, 0, sizeof(YAAMP_COIND)); coind->newcoind = true; coind->newblock = true; coind->id = atoi(row[0]); coind->aux.coind = coind; } else coind->newcoind = false; strcpy(coind->name, row[1]); if(row[7]) strcpy(coind->wallet, row[7]); if(row[6]) coind->pos = strcmp(row[6], "POS")? false: true; if(row[10]) coind->hassubmitblock = atoi(row[10]); if(row[2]) strcpy(coind->rpc.host, row[2]); if(row[3]) coind->rpc.port = atoi(row[3]); if(row[4] && row[5]) { char buffer[1024]; sprintf(buffer, "%s:%s", row[4], row[5]); base64_encode(coind->rpc.credential, buffer); coind->rpc.coind = coind; } if(row[8]) coind->reward = atof(row[8]); if(row[9]) coind->price = atof(row[9]); if(row[11]) coind->txmessage = atoi(row[11]); if(row[12]) coind->enable = atoi(row[12]); if(row[13]) coind->auto_ready = atoi(row[13]); if(row[15]) coind->pool_ttf = atoi(row[15]); if(row[16]) strcpy(coind->charity_address, row[16]); if(row[17]) coind->charity_amount = atof(row[17]); if(row[18]) coind->charity_percent = atof(row[18]); if(row[19]) coind->reward_mul = atof(row[19]); strcpy(coind->symbol, row[20]); if(row[21]) coind->isaux = atoi(row[21]); if(row[22] && row[23]) coind->actual_ttf = min(atoi(row[22]), atoi(row[23])); else if(row[22]) coind->actual_ttf = atoi(row[22]); coind->actual_ttf = min(coind->actual_ttf, 120); coind->actual_ttf = max(coind->actual_ttf, 20); if(row[24]) coind->usememorypool = atoi(row[24]); //////////////////////////////////////////////////////////////////////////////////////////////////// coind->touch = true; if(coind->newcoind) { debuglog("connecting to coind %s\n", coind->symbol); bool b = rpc_connect(&coind->rpc); coind_init(coind); g_list_coind.AddTail(coind); usleep(100*YAAMP_MS); } coind_create_job(coind); } mysql_free_result(result); for(CLI li = g_list_coind.first; li; li = li->next) { YAAMP_COIND *coind = (YAAMP_COIND *)li->data; if(coind->deleted) continue; if(!coind->touch) { debuglog("remove coind %s\n", coind->name); rpc_close(&coind->rpc); object_delete(coind); continue; } coind->touch = false; } coind_sort(); g_list_coind.Leave(); }