mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
stratum: new function to log with the date (start/stop)
it was hard to estimate the shares/day activity with only hours
This commit is contained in:
parent
1148fef011
commit
1e72d4fb81
3 changed files with 28 additions and 5 deletions
|
@ -35,6 +35,7 @@ bool g_autoexchange = true;
|
|||
|
||||
uint64_t g_max_shares = 0;
|
||||
uint64_t g_shares_counter = 0;
|
||||
uint64_t g_shares_log = 0;
|
||||
|
||||
time_t g_last_broadcasted = 0;
|
||||
YAAMP_DB *g_db = NULL;
|
||||
|
@ -217,7 +218,8 @@ int main(int argc, char **argv)
|
|||
struct rlimit rlim_threads = {0x8000, 0x8000};
|
||||
setrlimit(RLIMIT_NPROC, &rlim_threads);
|
||||
|
||||
stratumlog("* starting stratumd for %s on %s:%d\n", g_current_algo->name, g_tcp_server, g_tcp_port);
|
||||
stratumlogdate("starting stratum for %s on %s:%d\n",
|
||||
g_current_algo->name, g_tcp_server, g_tcp_port);
|
||||
|
||||
g_db = db_connect();
|
||||
if(!g_db) yaamp_error("Cant connect database");
|
||||
|
@ -308,19 +310,20 @@ void *monitor_thread(void *p)
|
|||
if(g_last_broadcasted + YAAMP_MAXJOBDELAY < time(NULL))
|
||||
{
|
||||
g_exiting = true;
|
||||
stratumlog("%s dead lock, exiting...\n", g_current_algo->name);
|
||||
stratumlogdate("%s dead lock, exiting...\n", g_current_algo->name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(g_max_shares && g_shares_counter) {
|
||||
|
||||
if((g_shares_counter % 5000u) == 0) {
|
||||
stratumlog("%s %luK shares...\n", g_current_algo->name, (g_shares_counter/10000u));
|
||||
if((g_shares_counter - g_shares_log) > 10000) {
|
||||
stratumlogdate("%s %luK shares...\n", g_current_algo->name, (g_shares_counter/1000u));
|
||||
g_shares_log = g_shares_counter;
|
||||
}
|
||||
|
||||
if(g_shares_counter > g_max_shares) {
|
||||
g_exiting = true;
|
||||
stratumlog("%s need a restart (%lu shares), exiting...\n", g_current_algo->name, g_max_shares);
|
||||
stratumlogdate("%s need a restart (%lu shares), exiting...\n", g_current_algo->name, g_max_shares);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,6 +193,25 @@ void stratumlog(const char *format, ...)
|
|||
}
|
||||
}
|
||||
|
||||
void stratumlogdate(const char *format, ...)
|
||||
{
|
||||
char buffer[YAAMP_SMALLBUFSIZE];
|
||||
char date[16];
|
||||
va_list args;
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
strftime(date, 16, "%Y-%m-%d", timeinfo);
|
||||
|
||||
va_start(args, format);
|
||||
vsprintf(buffer, format, args);
|
||||
va_end(args);
|
||||
|
||||
stratumlog("%s %s", date, buffer);
|
||||
}
|
||||
|
||||
bool yaamp_error(char const *message)
|
||||
{
|
||||
debuglog("ERROR: %d %s\n", errno, message);
|
||||
|
|
|
@ -61,6 +61,7 @@ void initlog(const char *algo);
|
|||
|
||||
void debuglog(const char *format, ...);
|
||||
void stratumlog(const char *format, ...);
|
||||
void stratumlogdate(const char *format, ...);
|
||||
void clientlog(YAAMP_CLIENT *client, const char *format, ...);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Reference in a new issue