Beispiel #1
0
        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 StatisticsManager(IConfigManager configManager, IPoolManager poolManager, IAlgorithmManager algorithmManager)
        {
            Pools      = poolManager;
            Algorithms = algorithmManager;

            _config = configManager.StatisticsConfig;
            _logger = Log.ForContext <StatisticsManager>();

            _recacheTimer = new Timer(Recache, null, Timeout.Infinite, Timeout.Infinite); // create the timer as disabled.
            Recache(null);                                                                // recache data initially.
        }
        public StatisticsManager(IConfigManager configManager, IPoolManager poolManager, IAlgorithmManager algorithmManager)
        {
            Pools = poolManager;
            Algorithms = algorithmManager;

            _config = configManager.StatisticsConfig;
            _logger = Log.ForContext<StatisticsManager>();

            _recacheTimer = new Timer(Recache, null, Timeout.Infinite, Timeout.Infinite); // create the timer as disabled.
            Recache(null); // recache data initially.
        }
Beispiel #4
0
 public AlgorithmsModule(IAlgorithmManager algorithmManager)
     : base("/algorithms")
 {
     Get["/"] = _ =>
     {
         // return our view
         return(View["algorithms", new AlgorithmsModel
                     {
                         Algorithms = algorithmManager.GetAllAsReadOnly()
                     }]);
     };
 }
 public AlgorithmsModule(IAlgorithmManager algorithmManager)
     : base("/algorithms")
 {
     Get["/"] = _ =>
     {
         // return our view
         return View["algorithms", new AlgorithmsModel
         {
             Algorithms = algorithmManager.GetAllAsReadOnly()
         }];
     };
 }
        public IndexModule(IStatisticsManager statisticsManager, IPoolManager poolManager, IAlgorithmManager algorithmManager)
        {
            Get["/"] = _ =>
            {
                // include common data required by layout.
                ViewBag.Header = "Welcome";

                // return our view
                return View["index", new IndexModel
                {
                    Pools = poolManager.GetAllAsReadOnly(),
                    Algorithms = algorithmManager.GetAllAsReadOnly(),
                    Statistics = statisticsManager
                }];
            };
        }
Beispiel #7
0
        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);
        }
Beispiel #9
0
        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
                }];
            };
        }
Beispiel #11
0
        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);
            };
        }
Beispiel #12
0
        public IndexModule(IStatisticsManager statisticsManager, IPoolManager poolManager, IAlgorithmManager algorithmManager)
        {
            var model = new IndexModel
            {
                Pools      = poolManager.GetAllAsReadOnly(),
                Algorithms = algorithmManager.GetAllAsReadOnly(),
                Statistics = statisticsManager
            };

            Get["/"] = _ =>
            {
                // include common data required by layout.
                ViewBag.Header = "Welcome";

                // return our view
                return(View["index", model]);
            };
        }
Beispiel #13
0
        // 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);
            };
        }