From 102c4d4088774af5822ab8e645ca15c7e07c3dd9 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 9 Jul 2011 17:06:30 +1000 Subject: [PATCH] Give meaningful message on submission failure and resumption instead of spam. --- main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index efc1c533..53926d3d 100644 --- a/main.c +++ b/main.c @@ -495,6 +495,8 @@ static inline void print_status(void) fflush(stdout); } +static bool submit_fail = false; + static bool submit_upstream_work(const struct work *work) { char *hexstr = NULL; @@ -528,8 +530,15 @@ static bool submit_upstream_work(const struct work *work) /* issue JSON-RPC request */ val = json_rpc_call(curl, rpc_url, rpc_userpass, s, false, false); if (unlikely(!val)) { - applog(LOG_ERR, "submit_upstream_work json_rpc_call failed"); + applog(LOG_INFO, "submit_upstream_work json_rpc_call failed"); + if (!submit_fail) { + submit_fail = true; + applog(LOG_WARNING, "Upstream communication failure, caching submissions"); + } goto out; + } else if (submit_fail) { + submit_fail = false; + applog(LOG_WARNING, "Upstream communication resumed, submitting work"); } res = json_object_get(val, "result"); @@ -711,14 +720,14 @@ static void *submit_work_thread(void *userdata) goto out; } if (unlikely(strncmp(hexstr, current_block, 36))) { - applog(LOG_INFO, "Stale work detected, discarding"); + applog(LOG_WARNING, "Stale work detected, discarding"); goto out_free; } /* submit solution to bitcoin via JSON-RPC */ while (!submit_upstream_work(wc->u.work)) { if (unlikely(strncmp(hexstr, current_block, 36))) { - applog(LOG_INFO, "Stale work detected, discarding"); + applog(LOG_WARNING, "Stale work detected, discarding"); goto out_free; } if (unlikely((opt_retries >= 0) && (++failures > opt_retries))) { @@ -728,7 +737,7 @@ static void *submit_work_thread(void *userdata) } /* pause, then restart work-request loop */ - applog(LOG_ERR, "json_rpc_call failed on submit_work, retry after %d seconds", + applog(LOG_INFO, "json_rpc_call failed on submit_work, retry after %d seconds", opt_fail_pause); sleep(opt_fail_pause); }