getStats(); */ class PoolClient { private string $apiUrl; private int $cacheTtl; public function __construct() { $this->apiUrl = config('pool.api_url', 'http://127.0.0.1:2117'); $this->cacheTtl = config('pool.cache_ttl', 15); } public function getStats(): array { return Cache::remember('pool.stats', $this->cacheTtl, function () { try { $response = Http::timeout(5)->get("{$this->apiUrl}/stats"); return $response->successful() ? ($response->json() ?? []) : []; } catch (\Throwable) { return []; } }); } public function getBlocks(): array { return Cache::remember('pool.blocks', $this->cacheTtl, function () { try { $response = Http::timeout(5)->get("{$this->apiUrl}/get_blocks"); return $response->successful() ? ($response->json() ?? []) : []; } catch (\Throwable) { return []; } }); } public function getPayments(): array { return Cache::remember('pool.payments', $this->cacheTtl, function () { try { $response = Http::timeout(5)->get("{$this->apiUrl}/get_payments"); return $response->successful() ? ($response->json() ?? []) : []; } catch (\Throwable) { return []; } }); } public function getMinerStats(string $address): array { try { $response = Http::timeout(5)->get("{$this->apiUrl}/stats_address", [ 'address' => $address, ]); return $response->successful() ? ($response->json() ?? []) : []; } catch (\Throwable) { return []; } } }