Skip to content

Commit

Permalink
Fixed /blocks pagination.
Browse files Browse the repository at this point in the history
Fixed /blocks/page/{id} route.
Added site field to coin-config.
HybridStorage.Blocks.cs:GetPaidBlocks() now really returns paid blocks only :)
  • Loading branch information
bonesoul committed Sep 24, 2014
1 parent 21e4507 commit 0cfe6bc
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/CoiniumServ/Coin/Config/CoinConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class CoinConfig : ICoinConfig

public string Algorithm { get; private set; }

public string Site { get; private set; }

public ICoinOptions Options { get; private set; }

public IBlockExplorerOptions BlockExplorer { get; private set; }
Expand All @@ -49,6 +51,7 @@ public CoinConfig(dynamic config)
Name = config.name;
Symbol = config.symbol;
Algorithm = config.algorithm;
Site = string.IsNullOrEmpty(config.site) ? string.Empty : config.site;
Options = new CoinOptions(config.options);
BlockExplorer = new BlockExplorerOptions(config.blockExplorer);
Extra = config.extra;
Expand Down
6 changes: 6 additions & 0 deletions src/CoiniumServ/Coin/Config/ICoinConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public interface ICoinConfig:IConfig
[JsonProperty("algorithm")]
string Algorithm { get; }

/// <summary>
///
/// </summary>
[JsonProperty("site")]
string Site { get; }

ICoinOptions Options { get; }

IBlockExplorerOptions BlockExplorer { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ public IList<IPersistedBlock> GetPaidBlocks(IPaginationQuery paginationQuery)
using (var connection = new MySqlConnection(_mySqlProvider.ConnectionString))
{
var results = connection.Query<PersistedBlock>(string.Format(
@"SELECT Height, Orphaned, Confirmed, Accounted, BlockHash, TxHash, Amount, Reward, CreatedAt From Block
WHERE Accounted = true ORDER BY Height DESC LIMIT {0},{1}", paginationQuery.Offset, paginationQuery.Count));
@"SELECT b.Height, b.Orphaned, b.Confirmed, b.Accounted, b.BlockHash, b.TxHash, b.Amount, b.Reward, b.CreatedAt
From Block b
INNER JOIN Payment as p ON p.Block = b.Height
WHERE b.Accounted = true and p.Completed = true
ORDER BY Height DESC LIMIT {0},{1}", paginationQuery.Offset, paginationQuery.Count));

blocks.AddRange(results);
}
Expand Down
8 changes: 8 additions & 0 deletions src/CoiniumServ/Server/Web/Models/Pool/BlocksModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public class BlocksModel

public ICoinConfig Coin { get; set; }

public BlockFilter Filter { get; set; }

public IPaginationQuery PaginationQuery { get; set; }
}

public enum BlockFilter
{
All,
PaidOnly
}
}
6 changes: 4 additions & 2 deletions src/CoiniumServ/Server/Web/Modules/PoolModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public PoolModule(IPoolManager poolManager)
}];
};

Get["/{slug}/blocks/paid{page?1}"] = _ =>
Get["/{slug}/blocks/paid/{page?1}"] = _ =>
{
var pool = (IPool)poolManager.Get(_.slug); // find the requested pool.
Expand Down Expand Up @@ -134,13 +134,14 @@ public PoolModule(IPoolManager poolManager)
{
Blocks = blocks,
Coin = pool.Config.Coin,
Filter = BlockFilter.PaidOnly,
PaginationQuery = paginationQuery
};
return View["blocks", model];
};

Get["/{slug}/blocks/latest/{page?1}"] = _ =>
Get["/{slug}/blocks/{page?1}"] = _ =>
{
var pool = (IPool)poolManager.Get(_.slug); // find the requested pool.
Expand Down Expand Up @@ -172,6 +173,7 @@ public PoolModule(IPoolManager poolManager)
{
Blocks = blocks,
Coin = pool.Config.Coin,
Filter = BlockFilter.All,
PaginationQuery = paginationQuery
};
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/web/default/views/index/index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<div class="col-xs-9 text-right">
<h3>@Model.Statistics.Hashrate.GetReadableHashrate()</h3>
<div>Hashrate</div>
<div>Overall Hashrate</div>
</div>
</div>
</div>
Expand Down
12 changes: 9 additions & 3 deletions src/CoiniumServ/web/default/views/pool/blocks.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@using CoiniumServ.Persistance.Blocks
@using System.Linq
@using CoiniumServ.Persistance.Blocks
@using CoiniumServ.Server.Web.Models.Pool
@using Nancy
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<CoiniumServ.Server.Web.Models.Pool.BlocksModel>
@{ Layout = "layout/main.cshtml"; }

Expand Down Expand Up @@ -54,7 +57,10 @@

<div class="row">
<div class="col-md-12">
<a href="/pool/@Model.Coin.Symbol/blocks/latest/@(Model.PaginationQuery.Page - 1)" type="button" class="btn btn-default btn-sm"><i class="fa fa-angle-double-left"></i> Prev</a>
<a href="/pool/@Model.Coin.Symbol/blocks/latest/@(Model.PaginationQuery.Page + 1)" type="button" class="btn btn-default btn-sm pull-right"><i class="fa fa-angle-double-right"></i> Next</a>
@if (Model.PaginationQuery.Page - 1 >= 1)
{
<a href="/pool/@Model.Coin.Symbol/blocks/@(Model.Filter == BlockFilter.PaidOnly ? "paid" : "")@(Model.PaginationQuery.Page - 1)" type="button" class="btn btn-default btn-sm"><i class="fa fa-angle-double-left"></i> Prev</a>
}
<a href="/pool/@Model.Coin.Symbol/blocks/@(Model.Filter == BlockFilter.PaidOnly ?"paid" : "")@(Model.PaginationQuery.Page + 1)" type="button" class="btn btn-default btn-sm pull-right"><i class="fa fa-angle-double-right"></i> Next</a>
</div>
</div>
61 changes: 51 additions & 10 deletions src/CoiniumServ/web/default/views/pool/pool.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</div>
</div>
</div>

<div class="col-md-4">
<div class="box box-solid box-warning">
<div class="box-header">
Expand Down Expand Up @@ -122,9 +122,35 @@
</div>
</div>

<div class="callout callout-info">
<h4><i class="ion ion-arrow-right-b"></i> Get Started</h4>
<p>Follow our <a href="/help/gettingstarted/pool/@Model.Pool.Config.Coin.Symbol">getting started guide</a> to start mining @Model.Pool.Config.Coin.Name's now!</p>
<div class="row">
<div class="col-md-6">
<div class="small-box bg-blue-gradient">
<div class="inner">
<h3><img src="/Content/img/coins/icon/@(Model.Pool.Config.Coin.Symbol).png" /> @Model.Pool.Config.Coin.Symbol (@Model.Pool.Config.Coin.Algorithm)</h3>
<p>Check the official site for more information about @Model.Pool.Config.Coin.Name</p>
</div>
<div class="icon">
<i class="ion ion-information-circled"></i>
</div>
<a href="@Model.Pool.Config.Coin.Site" target="_blank" class="small-box-footer">
@Model.Pool.Config.Coin.Site <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div>
<div class="col-md-6">
<div class="small-box bg-purple-gradient">
<div class="inner">
<h3>Get Started</h3>
<p>Follow our getting started guide to start mining now!</p>
</div>
<div class="icon">
<i class="ion ion-flash"></i>
</div>
<a href="/help/gettingstarted/pool/@Model.Pool.Config.Coin.Symbol" class="small-box-footer">
Getting Started <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div>
</div>

<div class="row">
Expand All @@ -133,7 +159,7 @@
<div class="box-header">
<h3 class="box-title"><i class="fa fa-hdd-o"></i> Latest Blocks</h3>
<div class="box-tools pull-right">
<a href="/pool/@Model.Pool.Config.Coin.Symbol/blocks/latest/" type="button" class="btn btn-primary"><i class="fa fa-angle-double-right"></i></a>
<a href="/pool/@Model.Pool.Config.Coin.Symbol/blocks/" type="button" class="btn btn-primary"><i class="fa fa-angle-double-right"></i></a>
</div>
</div>
<div class="box-body no-padding">
Expand All @@ -156,10 +182,10 @@
<span class="label label-warning">@block.Status</span>
break;
case BlockStatus.Orphaned:
<span class="label label-danger">@block.Status</span>
<span class="label label-danger">@block.Status</span>
break;
case BlockStatus.Confirmed:
<span class="label label-info">@block.Status</span>
<span class="label label-info">@block.Status</span>
break;
}
</td>
Expand All @@ -170,6 +196,14 @@
</tbody>
</table>
</div>
<div class="box-footer">
<div class="input-group">
<div class="input-group-btn">
<button type="button" class="btn btn-primary"><i class="fa fa-search"></i> Lookup</button>
</div>
<input type="text" class="form-control" placeholder="Enter block height..">
</div>
</div>
</div>
</div>

Expand Down Expand Up @@ -201,10 +235,10 @@
<span class="label label-warning">@block.Status</span>
break;
case BlockStatus.Orphaned:
<span class="label label-danger">@block.Status</span>
<span class="label label-danger">@block.Status</span>
break;
case BlockStatus.Confirmed:
<span class="label label-info">@block.Status</span>
<span class="label label-info">@block.Status</span>
break;
}
</td>
Expand All @@ -215,8 +249,15 @@
</tbody>
</table>
</div>
<div class="box-footer">
<div class="input-group">
<div class="input-group-btn">
<button type="button" class="btn btn-danger"><i class="fa fa-search"></i> Lookup</button>
</div>
<input type="text" class="form-control" placeholder="Enter your wallet address..">
</div>
</div>
</div>
</div>

</div>

0 comments on commit 0cfe6bc

Please sign in to comment.