upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/main/tollgate_main.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 04:13:11 +0530
committerYour Name <you@example.com>2026-05-19 04:13:11 +0530
commitbeb73a2eeacf7dbe5e292ce6e26a95a933808267 (patch)
tree3a9b711e1475c09ed544b96358587df3e5362555 /main/tollgate_main.c
parentc75230e551a778408b2e370b208aff76b74c6560 (diff)
feat(mining): integrate mining subsystem into existing modules
- CMakeLists.txt: add 6 mining sources + tcp_transport dependency - config.h/c: mining_payout_mode_t enum, mining config fields, JSON parsing - tollgate_main.c: mining init in start_services(), stratum_client_tick in main loop - tollgate_api.c: GET /mining/job, POST /mining/share, GET /mining/stats endpoints - session.h/c: payment_method_t enum (CASHU/MINING/BYTES) - firewall.h/c: sandbox allowlist for mining port + mint URLs - tollgate_client.h/c: TG_CLIENT_MINING state, mining discovery tag parsing - captive_portal.c: tabbed UI with Cashu/Mine tabs, live hashrate polling
Diffstat (limited to 'main/tollgate_main.c')
-rw-r--r--main/tollgate_main.c31
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
28static const char *TAG = "tollgate_main"; 33static 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}