stratum: fill new port workers and symbol fields

This commit is contained in:
Tanguy Pruvot 2018-01-01 12:30:39 +01:00
parent 31163c3933
commit 472b4d7635

View file

@ -87,12 +87,17 @@ void db_register_stratum(YAAMP_DB *db)
int t = time(NULL);
if(!db) return;
db_query(db, "insert into stratums (pid, time, algo) values (%d, %d, '%s') on duplicate key update time=%d",
pid, t, g_current_algo->name, t);
db_query(db, "INSERT INTO stratums (pid, time, algo, port) VALUES (%d, %d, '%s', %d) "
" ON DUPLICATE KEY UPDATE time=%d, algo='%s', port=%d",
pid, t, g_stratum_algo, g_tcp_port,
t, g_stratum_algo, g_tcp_port
);
}
void db_update_algos(YAAMP_DB *db)
{
int pid = getpid();
//int fds = 0; // todo, sample: ls -l /proc/$PID/fd | grep socket | grep -c .
if(!db) return;
if(g_current_algo->overflow)
@ -100,9 +105,20 @@ void db_update_algos(YAAMP_DB *db)
debuglog("setting overflow\n");
g_current_algo->overflow = false;
db_query(db, "update algos set overflow=true where name='%s'", g_current_algo->name);
db_query(db, "UPDATE algos SET overflow=true WHERE name='%s'", g_stratum_algo);
}
char symbol[16] = "NULL\0";
if(g_list_coind.count == 1) {
if (g_list_coind.first) {
CLI li = g_list_coind.first;
YAAMP_COIND *coind = (YAAMP_COIND *)li->data;
sprintf(symbol,"'%s'", coind->symbol);
}
}
db_query(db, "UPDATE stratums SET workers=%d, symbol=%s WHERE pid=%d", g_list_client.count, symbol, pid);
///////////////////////////////////////////////////////////////////////////////////////////
db_query(db, "select name, profit, rent, factor from algos");