We allow 60 seconds of spurious errors, eg. reorg. */
| 209 | |
| 210 | /* We allow 60 seconds of spurious errors, eg. reorg. */ |
| 211 | static void bcli_failure(struct bitcoin_cli *bcli, |
| 212 | int exitstatus) |
| 213 | { |
| 214 | struct timerel t; |
| 215 | |
| 216 | if (!bitcoind->error_count) |
| 217 | bitcoind->first_error_time = time_mono(); |
| 218 | |
| 219 | t = timemono_between(time_mono(), bitcoind->first_error_time); |
| 220 | if (time_greater(t, time_from_sec(bitcoind->retry_timeout))) |
| 221 | plugin_err(bcli->cmd->plugin, |
| 222 | "%s exited %u (after %u other errors) '%.*s'; " |
| 223 | "we have been retrying command for " |
| 224 | "--bitcoin-retry-timeout=%"PRIu64" seconds; " |
| 225 | "bitcoind setup or our --bitcoin-* configs broken?", |
| 226 | bcli_args(bcli), |
| 227 | exitstatus, |
| 228 | bitcoind->error_count, |
| 229 | (int)bcli->output_bytes, |
| 230 | bcli->output, |
| 231 | bitcoind->retry_timeout); |
| 232 | |
| 233 | plugin_log(bcli->cmd->plugin, LOG_UNUSUAL, "%s exited with status %u", |
| 234 | bcli_args(bcli), exitstatus); |
| 235 | bitcoind->error_count++; |
| 236 | |
| 237 | /* Retry in 1 second */ |
| 238 | plugin_timer(bcli->cmd->plugin, time_from_sec(1), retry_bcli, bcli); |
| 239 | } |
| 240 | |
| 241 | static void bcli_finished(struct io_conn *conn UNUSED, struct bitcoin_cli *bcli) |
| 242 | { |
no test coverage detected