public HelpModule(IPoolManager poolManager, IConfigManager configManager, ISoftwareRepository softwareRepository) : base("/help") { Get["/faq"] = _ => { ViewBag.Header = "Frequently Asked Questions"; return(View["faq"]); }; Get["/gettingstarted/"] = _ => { var model = new GettingStartedModel { Stack = configManager.StackConfig, Pool = poolManager.Get(slug) }; ViewBag.ActiveLink = "help"; return(View["gettingstarted/index", model]); }; Get["/miningsoftware/"] = _ => { ViewBag.ActiveLink = "help"; return(View["miningsoftware", softwareRepository]); }; }
// 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 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 HelpModule(IPoolManager poolManager, IConfigManager configManager, ISoftwareRepository softwareRepository) : base("/help") { Get["/faq"] = _ => { ViewBag.Header = "Frequently Asked Questions"; return(View["faq"]); }; Get["/gettingstarted/"] = _ => { var model = new GettingStartedModel { Stack = configManager.StackConfig, Pools = poolManager.GetAllAsReadOnly() }; return(View["gettingstarted/index", model]); }; Get["/gettingstarted/pool/{slug}"] = _ => { var pool = poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]); } var model = new GettingStartedPoolModel { Stack = configManager.StackConfig, Pool = pool }; return(View["gettingstarted/pool", model]); }; Get["/miningsoftware/"] = _ => { return(View["miningsoftware", softwareRepository]); }; }
public HelpModule(IPoolManager poolManager, IConfigManager configManager, ISoftwareRepository softwareRepository) : base("/help") { Get["/faq"] = _ => { ViewBag.Header = "Frequently Asked Questions"; return View["faq"]; }; Get["/gettingstarted/"] = _ => { var model = new GettingStartedModel { Stack = configManager.StackConfig, Pools = poolManager.GetAllAsReadOnly() }; return View["gettingstarted/index", model]; }; Get["/gettingstarted/pool/{slug}"] = _ => { var pool = poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } var model = new GettingStartedPoolModel { Stack = configManager.StackConfig, Pool = pool }; return View["gettingstarted/pool", model]; }; Get["/miningsoftware/"] = _ => { return View["miningsoftware", softwareRepository]; }; }
public IndexModule(IPoolManager poolManager) { Get["/"] = _ => { var pool = poolManager.Get(slug); // find the requested pool. if (pool == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } ViewBag.Title = string.Format("{0} Mining Pool", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Mining Pool", pool.Config.Coin.Name); // return our view return(View["pool", new PoolModel { Pool = pool }]); }; Get["/workers"] = _ => { var pool = poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } ViewBag.Header = string.Format("{0} Workers", pool.Config.Coin.Name); // return our view return(View["workers", new WorkersModel { Workers = pool.MinerManager.Miners }]); }; Get["/round"] = _ => { var pool = poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } ViewBag.Header = string.Format("{0} Current Round", pool.Config.Coin.Name); // return our view return(View["round", new RoundModel { Round = pool.NetworkInfo.Round, Shares = pool.RoundShares }]); }; Get["/blocks/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } int page; if (!Int32.TryParse(_.page, out page)) { page = 1; } var paginationQuery = new PaginationQuery(page); var blocks = pool.BlockRepository.GetBlocks(paginationQuery); if (blocks.Count == 0) { return(View["error", new ErrorViewModel { Details = "No more blocks exist" }]); } var model = new BlocksModel { Blocks = blocks, Coin = pool.Config.Coin, Filter = BlockFilter.All, PaginationQuery = paginationQuery }; return(View["blocks", model]); }; Get["/blocks/paid/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } int page; if (!Int32.TryParse(_.page, out page)) { page = 1; } var paginationQuery = new PaginationQuery(page); var blocks = pool.BlockRepository.GetPaidBlocks(paginationQuery); if (blocks.Count == 0) { return(View["error", new ErrorViewModel { Details = "No more blocks exist" }]); } var model = new BlocksModel { Blocks = blocks, Coin = pool.Config.Coin, Filter = BlockFilter.PaidOnly, PaginationQuery = paginationQuery }; return(View["blocks", model]); }; Get["/block/{height:int}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var block = pool.BlockRepository.Get((uint)_.height); if (block == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested block does not exist: {0}", _.height) }]); } var model = new BlockModel { Block = block, Coin = pool.Config.Coin, Payments = pool.PaymentRepository.GetPaymentDetailsForBlock((uint)_.height) }; ViewBag.Header = string.Format("Block {0}", block.Height); ViewBag.SubHeader = string.Format("{0} block", pool.Config.Coin.Name); return(View["block", model]); }; Get["/tx/{id:int}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var details = pool.PaymentRepository.GetPaymentDetailsByTransactionId((uint)_.id); if (details == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested transaction does not exist.") }]); } var account = pool.AccountManager.GetAccountById(details.AccountId); var block = pool.BlockRepository.Get((uint)details.Block); ViewBag.Header = string.Format("Transaction Details"); ViewBag.SubHeader = string.Format("{0}", details.TransactionId); var model = new PaymentDetailsModel { Details = details, Account = account, Block = block, Coin = pool.Config.Coin }; return(View["paymentdetails", model]); }; Get["/payment/{id:int}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var details = pool.PaymentRepository.GeyPaymentDetailsByPaymentId((uint)_.id); if (details == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested payment does not exist.") }]); } var account = pool.AccountManager.GetAccountById(details.AccountId); var block = pool.BlockRepository.Get((uint)details.Block); ViewBag.Header = string.Format("Payment Details"); ViewBag.SubHeader = string.Format("{0}", details.PaymentId); var model = new PaymentDetailsModel { Details = details, Account = account, Block = block, Coin = pool.Config.Coin }; return(View["paymentdetails", model]); }; Get["/account/username/{username}/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(slug); // find the requested pool. if (pool == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", slug) }]); } var account = (IAccount)pool.AccountManager.GetAccountByUsernameOrAddress(_.username); if (account == null) { return(View["error", new ErrorViewModel { Details = string.Format("The requested account does not exist: {0}", _.username) }]); } int page; if (!Int32.TryParse(_.page, out page)) { page = 1; } var paginationQuery = new PaginationQuery(page); // get the payments for the account. var payments = pool.AccountManager.GetPaymentsForAccount(account.Id, paginationQuery); ViewBag.Header = string.Format("Account Details"); ViewBag.SubHeader = account.Username; // return our view return(View["account", new AccountModel { Account = account, Coin = pool.Config.Coin, Payments = payments, PaginationQuery = paginationQuery }]); }; }
public PoolModule(IPoolManager poolManager) : base("/pool") { Get["/{slug}"] = _ => { var pool = poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } ViewBag.Title = string.Format("{0} Pool", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Pool", pool.Config.Coin.Name); // return our view return View["pool", new PoolModel { Pool = pool }]; }; Get["/{slug}/workers"] = _ => { var pool = poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) // make sure queried pool exists. { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } ViewBag.Header = string.Format("{0} Workers", pool.Config.Coin.Name); // return our view return View["workers", new WorkersModel { Workers = pool.MinerManager.Miners }]; }; Get["/{slug}/round"] = _ => { var pool = poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) // make sure queried pool exists. { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } ViewBag.Header = string.Format("{0} Current Round", pool.Config.Coin.Name); // return our view return View["round", new RoundModel { Round = pool.NetworkInfo.Round, Shares = pool.RoundShares }]; }; Get["/{slug}/blocks/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) // make sure queried pool exists. { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } int page; if (!Int32.TryParse(_.page, out page)) page = 1; var paginationQuery = new PaginationQuery(page); var blocks = pool.BlockRepository.GetBlocks(paginationQuery); if (blocks.Count == 0) { return View["error", new ErrorViewModel { Details = "No more blocks exist" }]; } var model = new BlocksModel { Blocks = blocks, Coin = pool.Config.Coin, Filter = BlockFilter.All, PaginationQuery = paginationQuery }; return View["blocks", model]; }; Get["/{slug}/blocks/paid/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) // make sure queried pool exists. { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } int page; if (!Int32.TryParse(_.page, out page)) page = 1; var paginationQuery = new PaginationQuery(page); var blocks = pool.BlockRepository.GetPaidBlocks(paginationQuery); if (blocks.Count == 0) { return View["error", new ErrorViewModel { Details = "No more blocks exist" }]; } var model = new BlocksModel { Blocks = blocks, Coin = pool.Config.Coin, Filter = BlockFilter.PaidOnly, PaginationQuery = paginationQuery }; return View["blocks", model]; }; Get["/{slug}/block/{height:int}"] = _ => { var pool = (IPool)poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) // make sure queried pool exists. { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } var block = pool.BlockRepository.Get((uint)_.height); if (block == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested block does not exist: {0}", _.height) }]; } var model = new BlockModel { Block = block, Coin = pool.Config.Coin, Payments = pool.PaymentRepository.GetPaymentDetailsForBlock((uint)_.height) }; ViewBag.Header = string.Format("Block {0}", block.Height); ViewBag.SubHeader = string.Format("{0} block", pool.Config.Coin.Name); return View["block", model]; }; Get["/{slug}/tx/{id:int}"] = _ => { var pool = (IPool)poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) // make sure queried pool exists. { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } var details = pool.PaymentRepository.GetPaymentDetailsByTransactionId((uint)_.id); if (details == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested transaction does not exist.") }]; } var account = pool.AccountManager.GetAccountById(details.AccountId); var block = pool.BlockRepository.Get((uint) details.Block); ViewBag.Header = string.Format("Transaction Details"); ViewBag.SubHeader = string.Format("{0}", details.TransactionId); var model = new PaymentDetailsModel { Details = details, Account = account, Block = block, Coin = pool.Config.Coin }; return View["paymentdetails", model]; }; Get["/{slug}/payment/{id:int}"] = _ => { var pool = (IPool)poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) // make sure queried pool exists. { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", _.slug) }]; } var details = pool.PaymentRepository.GeyPaymentDetailsByPaymentId((uint)_.id); if (details == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested payment does not exist.") }]; } var account = pool.AccountManager.GetAccountById(details.AccountId); var block = pool.BlockRepository.Get((uint)details.Block); ViewBag.Header = string.Format("Payment Details"); ViewBag.SubHeader = string.Format("{0}", details.PaymentId); var model = new PaymentDetailsModel { Details = details, Account = account, Block = block, Coin = pool.Config.Coin }; return View["paymentdetails", model]; }; Get["/{slug}/account/address/{address:length(26,34)}/{page?1}"] = _ => { var pool = (IPool)poolManager.Get(HttpUtility.HtmlEncode(_.slug)); // find the requested pool. if (pool == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested pool does not exist: {0}", HttpUtility.HtmlEncode(_.slug)) }]; } var account = (IAccount)pool.AccountManager.GetAccountByAddress(_.address); if (account == null) { return View["error", new ErrorViewModel { Details = string.Format("The requested account does not exist: {0}", _.address) }]; } int page; if (!Int32.TryParse(_.page, out page)) page = 1; var paginationQuery = new PaginationQuery(page); // get the payments for the account. var payments = pool.AccountManager.GetPaymentsForAccount(account.Id, paginationQuery); ViewBag.Header = string.Format("Account Details"); ViewBag.SubHeader = account.Username; // return our view return View["account", new AccountModel { Account = account, Coin = pool.Config.Coin, Payments = payments, PaginationQuery = paginationQuery }]; }; }
public PoolModule(IStatisticsManager statisticsManager, IPoolManager poolManager) : base("/pool") { Get["/{slug}"] = _ => { ViewBag.LastUpdate = statisticsManager.LastUpdate.ToString("HH:mm:ss tt zz"); // last statistics update. ViewBag.Pools = poolManager; var pool = poolManager.Get(_.slug); // find the requested pool. TODO: use IStatistics instead if (pool == null) // make sure queried pool exists. { ViewBag.Title = "Error"; ViewBag.Heading = "An error occured!"; return(View["error", new ErrorViewModel { Summary = "Pool not found", Details = string.Format("The requested pool does not exist: {0}", _.slug) }]); } ViewBag.Title = string.Format("{0} Pool", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Pool", pool.Config.Coin.Name); // return our view return(View["pool", new PoolModel { Pool = pool }]); }; Get["/{slug}/workers"] = _ => { ViewBag.LastUpdate = statisticsManager.LastUpdate.ToString("HH:mm:ss tt zz"); // last statistics update. ViewBag.Pools = poolManager; var pool = poolManager.Get(_.slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { ViewBag.Title = "Error"; ViewBag.Heading = "An error occured!"; return(View["error", new ErrorViewModel { Summary = "Pool not found", Details = string.Format("The requested pool does not exist: {0}", _.slug) }]); } ViewBag.Title = string.Format("{0} Workers", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Workers", pool.Config.Coin.Name); // return our view return(View["workers", new WorkersModel { Workers = pool.MinerManager.Miners }]); }; Get["/{slug}/round"] = _ => { ViewBag.LastUpdate = statisticsManager.LastUpdate.ToString("HH:mm:ss tt zz"); // last statistics update. ViewBag.Pools = poolManager; var pool = poolManager.Get(_.slug); // find the requested pool. if (pool == null) // make sure queried pool exists. { ViewBag.Title = "Error"; ViewBag.Heading = "An error occured!"; return(View["error", new ErrorViewModel { Summary = "Pool not found", Details = string.Format("The requested pool does not exist: {0}", _.slug) }]); } ViewBag.Title = string.Format("{0} Current Round", pool.Config.Coin.Name); ViewBag.Heading = string.Format("{0} Current Round", pool.Config.Coin.Name); // return our view return(View["round", new CurrentRoundModel { Round = pool.NetworkStats.Round, Shares = pool.RoundShares }]); }; }