diff options
Diffstat (limited to 'main/tollgate_main.c')
| -rw-r--r-- | main/tollgate_main.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c index fa7a692..30a63db 100644 --- a/main/tollgate_main.c +++ b/main/tollgate_main.c | |||
| @@ -23,6 +23,11 @@ | |||
| 23 | #include "tollgate_client.h" | 23 | #include "tollgate_client.h" |
| 24 | #include "lightning_payout.h" | 24 | #include "lightning_payout.h" |
| 25 | #include "cvm_server.h" | 25 | #include "cvm_server.h" |
| 26 | #include "stratum_client.h" | ||
| 27 | #include "stratum_proxy.h" | ||
| 28 | #include "sw_miner.h" | ||
| 29 | #include "asic_miner.h" | ||
| 30 | #include "mining_payment.h" | ||
| 26 | 31 | ||
| 27 | #define MAX_STA_RETRY 5 | 32 | #define MAX_STA_RETRY 5 |
| 28 | static const char *TAG = "tollgate_main"; | 33 | static const char *TAG = "tollgate_main"; |
| @@ -154,6 +159,11 @@ static void start_services(void) | |||
| 154 | session_manager_init(); | 159 | session_manager_init(); |
| 155 | 160 | ||
| 156 | const tollgate_config_t *cfg = tollgate_config_get(); | 161 | const tollgate_config_t *cfg = tollgate_config_get(); |
| 162 | if (cfg->mining_enabled) { | ||
| 163 | firewall_set_mining_port(cfg->mining_port); | ||
| 164 | firewall_set_sandbox_mint_access(cfg->mining_sandbox_mint_access); | ||
| 165 | } | ||
| 166 | |||
| 157 | nucula_wallet_init(cfg->mint_url); | 167 | nucula_wallet_init(cfg->mint_url); |
| 158 | lightning_payout_init(&cfg->payout); | 168 | lightning_payout_init(&cfg->payout); |
| 159 | 169 | ||
| @@ -175,6 +185,26 @@ static void start_services(void) | |||
| 175 | cvm_server_start(); | 185 | cvm_server_start(); |
| 176 | } | 186 | } |
| 177 | 187 | ||
| 188 | if (cfg2->mining_enabled) { | ||
| 189 | ESP_LOGI(TAG, "Mining subsystem enabled, initializing..."); | ||
| 190 | mining_payment_init(); | ||
| 191 | stratum_client_init(); | ||
| 192 | stratum_proxy_init(cfg2->mining_port); | ||
| 193 | |||
| 194 | if (cfg2->mining_payout_mode != MINING_PAYOUT_UPSTREAM) { | ||
| 195 | stratum_client_start(); | ||
| 196 | } | ||
| 197 | |||
| 198 | asic_miner_init(); | ||
| 199 | if (asic_miner_is_present()) { | ||
| 200 | asic_miner_start(); | ||
| 201 | ESP_LOGI(TAG, "ASIC miner started"); | ||
| 202 | } else { | ||
| 203 | sw_miner_start(); | ||
| 204 | ESP_LOGI(TAG, "Software miner started (no ASIC)"); | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 178 | s_services_running = true; | 208 | s_services_running = true; |
| 179 | if (s_services_mutex) xSemaphoreGive(s_services_mutex); | 209 | if (s_services_mutex) xSemaphoreGive(s_services_mutex); |
| 180 | ESP_LOGI(TAG, "=== TollGate services started ==="); | 210 | ESP_LOGI(TAG, "=== TollGate services started ==="); |
| @@ -329,5 +359,6 @@ void app_main(void) | |||
| 329 | session_tick(); | 359 | session_tick(); |
| 330 | tollgate_client_tick(); | 360 | tollgate_client_tick(); |
| 331 | lightning_payout_tick(); | 361 | lightning_payout_tick(); |
| 362 | stratum_client_tick(); | ||
| 332 | } | 363 | } |
| 333 | } | 364 | } |