// TODO: use base("/api"); public ApiModule(IStatisticsManager statisticsManager, IPoolManager poolManager, IAlgorithmManager algorithmManager) : base("/api") { Get["/"] = _ => { // include common data required by layout. ViewBag.Title = "API"; ViewBag.Heading = "Public API"; ViewBag.Pools = poolManager; ViewBag.LastUpdate = statisticsManager.LastUpdate.ToString("HH:mm:ss tt zz"); // last statistics update. // return our view return(View["api", new ApiModel { BaseUrl = Request.Url.SiteBase, Coin = poolManager.First().Config.Coin }]); }; Get["/pools"] = _ => { var response = (Response)poolManager.ServiceResponse; response.ContentType = "application/json"; return(response); }; Get["/pool/{slug}"] = _ => { var pool = poolManager.Get(_.slug); // query the requested pool. var response = pool != null ? (Response)pool.ServiceResponse : PoolNotFound; response.ContentType = "application/json"; return(response); }; Get["/algorithms"] = _ => { var response = (Response)algorithmManager.ServiceResponse; response.ContentType = "application/json"; return(response); }; Get["/algorithm/{slug}"] = _ => { var algorithm = algorithmManager.Get(_.slug); // query the requested pool. var response = algorithm != null ? (Response)algorithm.ServiceResponse : AlgorithmNotFound; response.ContentType = "application/json"; return(response); }; Get["/global"] = _ => { var response = (Response)statisticsManager.ServiceResponse; response.ContentType = "application/json"; return(response); }; }
public ApiModule(IStatisticsManager statisticsManager, IPoolManager poolManager, IAlgorithmManager algorithmManager) : base("/api") { Get["/"] = _ => { // include common data required by layout. ViewBag.Header = "Public API"; // return our view return(View["api", new ApiModel { BaseUrl = Request.Url.SiteBase, Coin = poolManager.First().Config.Coin }]); }; Get["/pools"] = _ => { var response = (Response)poolManager.ServiceResponse; response.ContentType = "application/json"; return(response); }; Get["/pool/{slug}"] = _ => { var pool = poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // query the requested pool. var response = pool != null ? (Response)pool.ServiceResponse : PoolNotFound; response.ContentType = "application/json"; return(response); }; Get["/algorithms"] = _ => { var response = (Response)algorithmManager.ServiceResponse; response.ContentType = "application/json"; return(response); }; Get["/algorithm/{slug}"] = _ => { var algorithm = algorithmManager.Get(HttpUtility.HtmlEncode(_.slug)); // query the requested pool. var response = algorithm != null ? (Response)algorithm.ServiceResponse : AlgorithmNotFound; response.ContentType = "application/json"; return(response); }; Get["/global"] = _ => { var response = (Response)statisticsManager.ServiceResponse; response.ContentType = "application/json"; return(response); }; }
public MiningSoftware(IAlgorithmManager algorithmManager, IMiningSoftwareConfig config) { Name = config.Name; if (config.Version != null) { Version = new Version(config.Version); } Algorithms = new List <IHashAlgorithm>(); foreach (var entry in config.Algorithms) { var algorithm = algorithmManager.Get(entry); if (algorithm == null) { continue; } Algorithms.Add(algorithm); } foreach (var entry in config.Platforms) { switch (entry) { case "ati": Platforms = Platforms | Platforms.Ati; break; case "asic": Platforms = Platforms | Platforms.Asic; break; case "cpu": Platforms = Platforms | Platforms.Cpu; break; case "nvidia": Platforms = Platforms | Platforms.Nvidia; break; } } Site = config.Site; Downloads = config.Downloads.Where(x => x.Value != null).ToDictionary(x => x.Key, x => x.Value); }
public MiningSoftware(IAlgorithmManager algorithmManager, IMiningSoftwareConfig config) { Name = config.Name; if(config.Version!=null) Version = new Version(config.Version); Algorithms = new List<IHashAlgorithmStatistics>(); foreach(var entry in config.Algorithms) { var algorithm = algorithmManager.Get(entry); if (algorithm == null) continue; Algorithms.Add(algorithm); } foreach (var entry in config.Platforms) { switch (entry) { case "ati": Platforms = Platforms | Platforms.Ati; break; case "asic": Platforms = Platforms | Platforms.Asic; break; case "cpu": Platforms = Platforms | Platforms.Cpu; break; case "nvidia": Platforms = Platforms | Platforms.Nvidia; break; } } Site = config.Site; Downloads = config.Downloads.Where(x => x.Value != null).ToDictionary(x => x.Key, x => x.Value); }
public AlgorithmModule(IAlgorithmManager algorithmManager) : base("/algorithm") { Get["/{slug}"] = _ => { var algorithm = algorithmManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested algorithm. if (algorithm == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested algorithm does not exist: {0}", _.slug) }]); } ViewBag.Header = algorithm.Name; return(View["algorithm", new AlgorithmModel { Algorithm = algorithm }]); }; }
public AlgorithmModule(IAlgorithmManager algorithmManager) : base("/algorithm") { Get["/{slug}"] = _ => { var algorithm = algorithmManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested algorithm. if (algorithm == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested algorithm does not exist: {0}", _.slug) }]; } ViewBag.Header = algorithm.Name; return View["algorithm", new AlgorithmModel { Algorithm = algorithm }]; }; }
public ApiModule(IStatisticsManager statisticsManager, IPoolManager poolManager, IAlgorithmManager algorithmManager) : base("/api") { Get["/"] = _ => { // include common data required by layout. ViewBag.Header = "Public API"; // return our view return View["api", new ApiModel { BaseUrl = Request.Url.SiteBase, Coin = poolManager.First().Config.Coin }]; }; Get["/pools"] = _ => { var response = (Response) poolManager.ServiceResponse; response.ContentType = "application/json"; return response; }; Get["/pool/{slug}"] = _ => { var pool = poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // query the requested pool. var response = pool != null ? (Response)pool.ServiceResponse : PoolNotFound; response.ContentType = "application/json"; return response; }; Get["/algorithms"] = _ => { var response = (Response)algorithmManager.ServiceResponse; response.ContentType = "application/json"; return response; }; Get["/algorithm/{slug}"] = _ => { var algorithm = algorithmManager.Get(HttpUtility.HtmlEncode(_.slug)); // query the requested pool. var response = algorithm != null ? (Response)algorithm.ServiceResponse : AlgorithmNotFound; response.ContentType = "application/json"; return response; }; Get["/global"] = _ => { var response = (Response) statisticsManager.ServiceResponse; response.ContentType = "application/json"; return response; }; }