diff --git a/src/rpc.ts b/src/rpc.ts index ce45d4b..78f9cf1 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -215,7 +215,7 @@ const handlers: Record = { const pageLimit = Math.min(Math.max(1, limit), MAX_PAGE_SIZE); const pageOffset = Math.max(0, offset || 0); - const allServices = await storage.getServicesByName(parsed.service, parsed.version); + const allServices = await storage.discoverServices(parsed.service, parsed.version, 1000, 0); const compatibleServices = filterCompatibleServices(allServices); // Get unique services per username with available offers @@ -260,14 +260,12 @@ const handlers: Record = { } // Mode 3: Random discovery without username - const allServices = await storage.getServicesByName(parsed.service, parsed.version); - const compatibleServices = filterCompatibleServices(allServices); + const randomService = await storage.getRandomService(parsed.service, parsed.version); - if (compatibleServices.length === 0) { + if (!randomService) { throw new Error('No services found'); } - const randomService = compatibleServices[Math.floor(Math.random() * compatibleServices.length)]; const availableOffer = await findAvailableOffer(randomService); if (!availableOffer) {