mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-30 15:20:36 +00:00
stratum: log rejected blocks in a special file
This commit is contained in:
parent
719a2fb38f
commit
066da4d8e1
4 changed files with 51 additions and 0 deletions
|
@ -288,6 +288,7 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL
|
|||
|
||||
else {
|
||||
debuglog("*** REJECTED :( %s block %d %d txs\n", coind->name, templ->height, templ->txcount);
|
||||
rejectlog("REJECTED %s block %d %s\n", coind->symbol, templ->height, block_hex);
|
||||
#ifdef HASH_DEBUGLOG_
|
||||
//debuglog("block %s\n", block_hex);
|
||||
debuglog("--------------------------------------------------------------\n");
|
||||
|
|
|
@ -316,6 +316,8 @@ int main(int argc, char **argv)
|
|||
pthread_join(thread2, NULL);
|
||||
db_close(g_db); // client threads (called by stratum one)
|
||||
|
||||
closelogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ json_value *json_get_object(json_value *json, const char *name)
|
|||
FILE *g_debuglog = NULL;
|
||||
FILE *g_stratumlog = NULL;
|
||||
FILE *g_clientlog = NULL;
|
||||
FILE *g_rejectlog = NULL;
|
||||
|
||||
void initlog(const char *algo)
|
||||
{
|
||||
|
@ -98,6 +99,23 @@ void initlog(const char *algo)
|
|||
|
||||
g_stratumlog = fopen("stratum.log", "a");
|
||||
g_clientlog = fopen("client.log", "a");
|
||||
g_rejectlog = fopen("reject.log", "a");
|
||||
}
|
||||
|
||||
void closelogs()
|
||||
{
|
||||
if (g_debuglog) {
|
||||
fflush(g_debuglog); fclose(g_debuglog);
|
||||
}
|
||||
if (g_stratumlog) {
|
||||
fflush(g_stratumlog); fclose(g_stratumlog);
|
||||
}
|
||||
if (g_clientlog) {
|
||||
fflush(g_clientlog); fclose(g_clientlog);
|
||||
}
|
||||
if (g_rejectlog) {
|
||||
fflush(g_rejectlog); fclose(g_rejectlog);
|
||||
}
|
||||
}
|
||||
|
||||
void clientlog(YAAMP_CLIENT *client, const char *format, ...)
|
||||
|
@ -224,9 +242,37 @@ void stratumlogdate(const char *format, ...)
|
|||
stratumlog("%s %s", date, buffer);
|
||||
}
|
||||
|
||||
void rejectlog(const char *format, ...)
|
||||
{
|
||||
char buffer[YAAMP_SMALLBUFSIZE];
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsnprintf(buffer, YAAMP_SMALLBUFSIZE-1, format, args);
|
||||
va_end(args);
|
||||
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
char buffer2[80];
|
||||
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
strftime(buffer2, 80, "%H:%M:%S", timeinfo);
|
||||
printf("%s: %s", buffer2, buffer);
|
||||
|
||||
if(g_rejectlog)
|
||||
{
|
||||
fprintf(g_rejectlog, "%s: %s", buffer2, buffer);
|
||||
fflush(g_rejectlog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool yaamp_error(char const *message)
|
||||
{
|
||||
debuglog("ERROR: %d %s\n", errno, message);
|
||||
closelogs();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,11 +58,13 @@ bool yaamp_error(char const *message);
|
|||
const char *header_value(const char *data, const char *search, char *value);
|
||||
|
||||
void initlog(const char *algo);
|
||||
void closelogs();
|
||||
|
||||
void debuglog(const char *format, ...);
|
||||
void stratumlog(const char *format, ...);
|
||||
void stratumlogdate(const char *format, ...);
|
||||
void clientlog(YAAMP_CLIENT *client, const char *format, ...);
|
||||
void rejectlog(const char *format, ...);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue