From 95771d0c8614e527614889c529a223d2e45b5d3a Mon Sep 17 00:00:00 2001 From: Aristides Staffieri Date: Thu, 22 Feb 2024 16:00:23 -0700 Subject: [PATCH 1/2] adds a route to pass through rpc health --- src/route/index.ts | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/route/index.ts b/src/route/index.ts index df54834..2868dcf 100644 --- a/src/route/index.ts +++ b/src/route/index.ts @@ -27,7 +27,11 @@ import { XdrLargeInt, xdr, } from "stellar-sdk"; -import { buildTransfer, simulateTx } from "../helper/soroban-rpc"; +import { + SOROBAN_RPC_URLS, + buildTransfer, + simulateTx, +} from "../helper/soroban-rpc"; import { ERROR } from "../helper/error"; const API_VERSION = "v1"; @@ -103,6 +107,40 @@ export async function initApiServer( }, }); + instance.route({ + method: "GET", + url: "/rpc-health", + schema: { + querystring: { + ["network"]: { + type: "string", + validator: (qStr: string) => isNetwork(qStr), + }, + }, + }, + handler: async ( + request: FastifyRequest<{ + Querystring: { + ["network"]: NetworkNames; + }; + }>, + reply + ) => { + const networkUrl = SOROBAN_RPC_URLS[request.query.network]; + + if (!networkUrl) { + return reply.code(400).send("Unknown network"); + } + + const server = new SorobanRpc.Server(networkUrl, { + allowHttp: networkUrl.startsWith("http://"), + }); + + const health = await server.getHealth(); + reply.code(200).send(health); + }, + }); + instance.route({ method: "GET", url: "/feature-flags", From 63e68a07f2e92f8a0909baa45726fdc0b0e85be7 Mon Sep 17 00:00:00 2001 From: Aristides Staffieri Date: Thu, 22 Feb 2024 16:06:04 -0700 Subject: [PATCH 2/2] toggle soroban pubnet off --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 2dd3ee0..24d4912 100644 --- a/src/config.ts +++ b/src/config.ts @@ -33,7 +33,7 @@ export function buildConfig(config: Record) { redisPort: Number(config.REDIS_PORT) || Number(process.env.REDIS_PORT!), useMercury: config.USE_MERCURY === "true" || process.env.USE_MERCURY === "true", - useSorobanPublic: true, + useSorobanPublic: false, }; }