@@ -34,6 +34,8 @@ import (
3434 fiberlogger "github.com/gofiber/fiber/v2/middleware/logger"
3535 "github.com/gofiber/fiber/v2/middleware/recover"
3636
37+ chaintracksRoutes "github.com/bsv-blockchain/go-chaintracks/routes/fiber"
38+
3739 "github.com/bsv-blockchain/arcade/config"
3840 "github.com/bsv-blockchain/arcade/docs"
3941 "github.com/bsv-blockchain/arcade/logging"
@@ -97,6 +99,13 @@ func run(ctx context.Context, cfg *config.Config, log *slog.Logger) error {
9799 Logger : log ,
98100 })
99101
102+ // Setup chaintracks routes (if enabled and running in embedded mode)
103+ var chaintracksRts * chaintracksRoutes.Routes
104+ if cfg .ChaintracksServer .Enabled && services .Chaintracks != nil {
105+ chaintracksRts = chaintracksRoutes .NewRoutes (ctx , services .Chaintracks )
106+ log .Info ("Chaintracks HTTP API enabled" , slog .String ("routes" , "/chaintracks/v1/*, /chaintracks/v2/*" ))
107+ }
108+
100109 // Setup dashboard
101110 dashboard := NewDashboard (services .Arcade )
102111
@@ -107,7 +116,7 @@ func run(ctx context.Context, cfg *config.Config, log *slog.Logger) error {
107116 authToken = cfg .Auth .Token
108117 log .Info ("API authentication enabled" )
109118 }
110- app := setupServer (arcadeRoutes , dashboard , authToken )
119+ app := setupServer (arcadeRoutes , chaintracksRts , dashboard , authToken )
111120
112121 errCh := make (chan error , 1 )
113122 go func () {
@@ -118,7 +127,10 @@ func run(ctx context.Context, cfg *config.Config, log *slog.Logger) error {
118127
119128 log .Info ("Arcade started successfully" )
120129
121- // Wait for shutdown signal
130+ return waitForShutdown (ctx , cfg , log , app , errCh )
131+ }
132+
133+ func waitForShutdown (ctx context.Context , cfg * config.Config , log * slog.Logger , app * fiber.App , errCh <- chan error ) error {
122134 sigCh := make (chan os.Signal , 1 )
123135 signal .Notify (sigCh , os .Interrupt , syscall .SIGTERM )
124136
@@ -132,7 +144,6 @@ func run(ctx context.Context, cfg *config.Config, log *slog.Logger) error {
132144 log .Info ("Context canceled" )
133145 }
134146
135- // Graceful shutdown
136147 log .Info ("Shutting down gracefully" )
137148
138149 shutdownCtx , shutdownCancel := context .WithTimeout (ctx , cfg .Server .ShutdownTimeout )
@@ -146,7 +157,7 @@ func run(ctx context.Context, cfg *config.Config, log *slog.Logger) error {
146157 return nil
147158}
148159
149- func setupServer (arcadeRoutes * fiberRoutes.Routes , dashboard * Dashboard , authToken string ) * fiber.App {
160+ func setupServer (arcadeRoutes * fiberRoutes.Routes , chaintracksRts * chaintracksRoutes. Routes , dashboard * Dashboard , authToken string ) * fiber.App {
150161 app := fiber .New (fiber.Config {
151162 DisableStartupMessage : true ,
152163 })
@@ -168,6 +179,13 @@ func setupServer(arcadeRoutes *fiberRoutes.Routes, dashboard *Dashboard, authTok
168179 // Transaction endpoints (ARC-compatible)
169180 arcadeRoutes .Register (app )
170181
182+ // Chaintracks endpoints (block header tracking)
183+ if chaintracksRts != nil {
184+ chaintracksGroup := app .Group ("/chaintracks" )
185+ chaintracksRts .Register (chaintracksGroup .Group ("/v2" ))
186+ chaintracksRts .RegisterLegacy (chaintracksGroup .Group ("/v1" ))
187+ }
188+
171189 // Health check (standalone arcade server only)
172190 app .Get ("/health" , arcadeRoutes .HandleGetHealth )
173191
0 commit comments