diff --git a/doc/example_datum_gateway_config.json b/doc/example_datum_gateway_config.json index 667db6d7..6096edec 100644 --- a/doc/example_datum_gateway_config.json +++ b/doc/example_datum_gateway_config.json @@ -31,6 +31,7 @@ "migration_max_seconds": 86400, "pool_pass_workers": true, "pool_pass_full_users": true, - "pooled_mining_only": true + "pooled_mining_only": true, + "coinbaser_refetch": true } } diff --git a/src/datum_coinbaser.c b/src/datum_coinbaser.c index 439b08c8..20b1a0f2 100644 --- a/src/datum_coinbaser.c +++ b/src/datum_coinbaser.c @@ -911,7 +911,14 @@ void *datum_coinbaser_thread(void *ptr) { s->available_coinbase_outputs_count = 0; i = 0; } - if (i>=0) { + /* Pool mode only, and only when datum.coinbaser_refetch is true + * (the default). A short list is not done: keep the current job + * and ask again. Solo, or refetch disabled, publishes the local + * one-output coinbase and stops asking. */ + if (datum_config.datum_coinbaser_refetch && datum_protocol_is_active() && i < 2) { + DLOG_WARN("Coinbaser returned %d outputs (<2); not publishing one-output coinbase, will retry", i); + usleep(500000); + } else if (i>=0) { DLOG_DEBUG("Generating coinbases for up to %d outputs", i); generate_coinbase_txns_for_stratum_job(s, false); if (__builtin_expect(atomic_load_explicit(&need_coinbaser_rwlocks_init_done, memory_order_acquire), 1)) { diff --git a/src/datum_conf.c b/src/datum_conf.c index 3a890ffc..15dd6238 100644 --- a/src/datum_conf.c +++ b/src/datum_conf.c @@ -198,6 +198,9 @@ const T_DATUM_CONFIG_ITEM datum_config_options[] = { { .var_type = DATUM_CONF_BOOL, .category = "datum", .name = "pooled_mining_only", .description = "If the DATUM pool server becomes unavailable, terminate miner connections (otherwise, 100% of any blocks you find pay mining.pool_address)", .example_default = true, .required = false, .ptr = &datum_config.datum_pooled_mining_only, .default_bool = true }, + { .var_type = DATUM_CONF_BOOL, .category = "datum", .name = "coinbaser_refetch", .description = "While connected to a DATUM pool, if a coinbaser answer has fewer than 2 outputs, keep the current job and ask again. Set false to publish the one-output coinbase and stop asking until the next job. Ignored when the pool link is down.", + .example_default = true, + .required = false, .ptr = &datum_config.datum_coinbaser_refetch, .default_bool = true }, { .var_type = DATUM_CONF_INT, .category = "datum", .name = "protocol_global_timeout", .description = "If no valid messages are received from the DATUM server in this many seconds, give up and try to reconnect", .required = false, .ptr = &datum_config.datum_protocol_global_timeout, .default_int = 60 }, }; diff --git a/src/datum_conf.h b/src/datum_conf.h index f230419c..69f9c5a9 100644 --- a/src/datum_conf.h +++ b/src/datum_conf.h @@ -170,6 +170,7 @@ typedef struct { bool datum_pool_pass_workers; bool datum_pool_pass_full_users; bool datum_pooled_mining_only; + bool datum_coinbaser_refetch; char datum_pool_pubkey[1024]; int datum_protocol_global_timeout; uint64_t datum_protocol_global_timeout_ms;