Skip to content

Commit

Permalink
Merge pull request #645 from CoiniumServ/develop
Browse files Browse the repository at this point in the history
updates
  • Loading branch information
Hüseyin Uslu committed Oct 27, 2014
2 parents 9973e17 + 1ee4bd0 commit 88e0141
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 68 deletions.
6 changes: 5 additions & 1 deletion Changelog.md
Expand Up @@ -2,11 +2,15 @@

**Features**
* Implemented basic market data support initially from Cryptsy, Bittrex and Poloniex.

**Improvements**
* Marked miner connection, disconnection, share-submission log messages as debug level, so server.log file by default doesn't get spammed with them.
* Improved exception handlers for daemon connections.

**Bug Fixes**
* Fixed a bug in hybrid-storage where Block.Accounted and Payment.Completed fields default values was not set correctly.
* Fixed a bug in generation-transaction - version is now correctly set.
* Fixed a bug that was causing prevent frequent crashes.
* Fixed a bug in Payment Processor which was causing crashes for invalid addresses.

**Web**
* Added robots.txt
Expand Down
2 changes: 1 addition & 1 deletion src/CoiniumServ/Mining/MinerManager.cs
Expand Up @@ -141,7 +141,7 @@ public void Authenticate(IMiner miner)
// if username validation is not on just authenticate the miner, else ask the current storage layer to do so.
miner.Authenticated = !_poolConfig.Miner.ValidateUsername || _storageLayer.Authenticate(miner);

_logger.Information(
_logger.Debug(
miner.Authenticated ? "Authenticated miner: {0:l} [{1:l}]" : "Miner authentication failed: {0:l} [{1:l}]",
miner.Username, ((IClient) miner).Connection.RemoteEndPoint);

Expand Down
34 changes: 19 additions & 15 deletions src/CoiniumServ/Payments/PaymentProcessor.cs
Expand Up @@ -94,28 +94,32 @@ public void Run()

foreach (var payment in pendingPayments)
{
// query the user for the payment.
var user = _accountManager.GetAccountById(payment.AccountId);
try {
// query the user for the payment.
var user = _accountManager.GetAccountById(payment.AccountId);

if (user == null)
continue;
if (user == null) // if the user doesn't exist
continue; // just skip.

if (!perUserTransactions.ContainsKey(user.Username)) // check if our list of transactions to be executed already contains an entry for the user.
{
// if not, create an entry that contains the list of transactions for the user.
if (!perUserTransactions.ContainsKey(user.Username)) // check if our list of transactions to be executed already contains an entry for the user.
{
// if not, create an entry that contains the list of transactions for the user.

// see if user payout address is directly payable from the pool's main daemon connection
// which happens when a user connects an XYZ pool and want his payments in XYZ coin.
// see if user payout address is directly payable from the pool's main daemon connection
// which happens when a user connects an XYZ pool and want his payments in XYZ coin.

var result = _daemonClient.ValidateAddress(user.Address); // does the user have a directly payable address set?
var result = _daemonClient.ValidateAddress(user.Address); // does the user have a directly payable address set?

if (!result.IsValid) // if not skip the payment and let it handled by auto-exchange module.
continue;
if (!result.IsValid) // if not skip the payment and let it handled by auto-exchange module.
continue;

perUserTransactions.Add(user.Username, new List<ITransaction>());
}
perUserTransactions.Add(user.Username, new List<ITransaction>());
}

perUserTransactions[user.Username].Add(new Transaction(user, payment, _poolConfig.Coin.Symbol)); // add the payment to user.
perUserTransactions[user.Username].Add(new Transaction(user, payment, _poolConfig.Coin.Symbol)); // add the payment to user.
}
catch(RpcException)
{ } // on rpc exception; just skip the payment for now.
}

return perUserTransactions;
Expand Down
6 changes: 0 additions & 6 deletions src/CoiniumServ/Pools/IProfitInfo.cs
Expand Up @@ -43,13 +43,7 @@ public interface IProfitInfo
[JsonProperty("btcPerMhPerHour")]
double BtcPerMhPerHour { get; }

[JsonProperty("btcPerMhPerDay")]
double BtcPerMhPerDay { get; }

[JsonProperty("usdPerMhPerHour")]
double UsdPerMhPerHour { get; }

[JsonProperty("usdPerMhPerDay")]
double UsdPerMhPerDay { get; }
}
}
4 changes: 0 additions & 4 deletions src/CoiniumServ/Pools/ProfitInfo.cs
Expand Up @@ -46,10 +46,8 @@ public class ProfitInfo : IProfitInfo
public double CoinsPerMhPerHour { get; private set; }

public double BtcPerMhPerHour { get; private set; }
public double BtcPerMhPerDay { get; private set; }

public double UsdPerMhPerHour { get; private set; }
public double UsdPerMhPerDay { get; private set; }

public ProfitInfo(IMarketManager marketManager, INetworkInfo networkInfo, IPoolConfig poolConfig)
{
Expand Down Expand Up @@ -88,9 +86,7 @@ private void CalculateProfitability()
BlocksPerMhPerHour = interval / ((_networkInfo.Difficulty * Math.Pow(2, 32)) / hashrate);
CoinsPerMhPerHour = BlocksPerMhPerHour*_networkInfo.Reward;
BtcPerMhPerHour = CoinsPerMhPerHour*Convert.ToDouble(PriceInBtc);
BtcPerMhPerDay = BtcPerMhPerHour*24;
UsdPerMhPerHour = CoinsPerMhPerHour*Convert.ToDouble(PriceInUsd);
UsdPerMhPerDay = UsdPerMhPerHour*24;
}
}
}
6 changes: 3 additions & 3 deletions src/CoiniumServ/Server/Mining/Stratum/StratumServer.cs
Expand Up @@ -124,7 +124,7 @@ public override bool IsBanned(Socket socket)
/// <param name="e"></param>
private void OnClientConnection(object sender, ConnectionEventArgs e)
{
_logger.Information("Stratum client connected: {0}", e.Connection.ToString());
_logger.Debug("Stratum client connected: {0}", e.Connection.ToString());

// TODO: remove the jobManager dependency by instead injecting extranonce counter.
var miner = _minerManager.Create<StratumMiner>(_jobManager.ExtraNonce.Next(), e.Connection, _pool);
Expand All @@ -138,14 +138,14 @@ private void OnClientConnection(object sender, ConnectionEventArgs e)
/// <param name="e"></param>
private void OnClientDisconnect(object sender, ConnectionEventArgs e)
{
_logger.Information("Stratum client disconnected: {0}", e.Connection.ToString());
_logger.Debug("Stratum client disconnected: {0}", e.Connection.ToString());

_minerManager.Remove(e.Connection);
}

private void OnBannedConnection(object sender, BannedConnectionEventArgs e)
{
_logger.Information("Rejected connection from banned ip: {0:l}", e.Endpoint.Address.ToString());
_logger.Debug("Rejected connection from banned ip: {0:l}", e.Endpoint.Address.ToString());
}

/// <summary>
Expand Down
27 changes: 13 additions & 14 deletions src/CoiniumServ/web/default/views/partial/pools.cshtml
@@ -1,5 +1,4 @@
@using System
@using System.Linq
@using System.Linq
@using CoiniumServ.Utils.Helpers
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<System.Collections.Generic.IEnumerable<CoiniumServ.Pools.IPool>>

Expand All @@ -17,15 +16,15 @@
<thead>
<tr>
<th class="hidden-xs" style="width: 40px;"></th>
<th>Pool</th>
<th>Hashrate</th>
<th>Network</th>
<th>Difficulty</th>
<th class="hidden-xs">Profitability (BTC/Mh/Day)</th>
<th class="hidden-xs">Workers</th>
<th class="hidden-xs">Algorithm</th>
<th class="hidden-xs">Last Block</th>
<th class="hidden-xs">Status</th>
<th title="Pool's name">Pool</th>
<th title="Total hashrate of the pool">Hashrate</th>
<th title="Total hashrate of the network">Network</th>
<th title="Difficulty of the network">Difficulty</th>
<th class="hidden-xs" title="Profitability of pool in USD for 1 MH/s per hour">Profitability</th>
<th class="hidden-xs" title="Number of connected workers">Workers</th>
<th class="hidden-xs" title="The algorithm used by the pool">Algorithm</th>
<th class="hidden-xs" title="Time of the last found block">Last Block</th>
<th class="hidden-xs" title="Status of the pool">Status</th>
</tr>
</thead>
<tbody>
Expand All @@ -37,14 +36,14 @@
<td>@pool.Hashrate.GetReadableHashrate()</td>
<td>@pool.NetworkInfo.Hashrate.GetReadableHashrate()</td>
<td title="@string.Format("{0:n8}",pool.NetworkInfo.Difficulty)">@pool.NetworkInfo.Difficulty.GetReadableDifficulty()</td>
<td>@pool.ProfitInfo.BtcPerMhPerDay</td>
<td>@(pool.ProfitInfo.UsdPerMhPerHour > 0 ? string.Format("{0:n2} $/hour", pool.ProfitInfo.UsdPerMhPerHour) : "N/A")</td>
<td class="hidden-xs">@pool.MinerManager.Count</td>
<td class="hidden-xs"><a href="/algorithm/@pool.Config.Coin.Algorithm">@pool.Config.Coin.Algorithm</a></td>
<td class="hidden-xs">
@{
var lastBlock = pool.BlockRepository.Latest.Count > 0 ? pool.BlockRepository.Latest.First().CreatedAt.ToString("yyyy-MM-ddTHH:mm:ssZ") : "N/A";
var lastBlock = pool.BlockRepository.Latest.Count > 0 ? pool.BlockRepository.Latest.First().CreatedAt.ToString("yyyy-MM-ddTHH:mm:ssZ") : "N/A";
<time class="timeago" datetime="@lastBlock">@lastBlock</time>
}
}
</td>
<td class="hidden-xs">
<div class="label @(pool.NetworkInfo.Healthy? "label-info" : "label-danger")">@(pool.NetworkInfo.Healthy ? "Healthy" : "Warnings!")</div>
Expand Down
62 changes: 38 additions & 24 deletions src/CoiniumServ/web/default/views/pool/pool.cshtml
Expand Up @@ -317,40 +317,54 @@
</div>
<div class="box-body no-padding">
<div class="list-group">
<div class="list-group-item" title="Best market price in BTC">
<div class="row">
<div class="col-xs-6"><i class="fa fa-btc"></i> Price In BTC</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInBtc <i class="fa fa-btc"></i></div>
@if (Model.Pool.ProfitInfo.PriceInBtc > 0)
{
<div class="list-group-item" title="Best market price in BTC">
<div class="row">
<div class="col-xs-6"><i class="fa fa-btc"></i> Price In BTC</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInBtc <i class="fa fa-btc"></i></div>
</div>
</div>
</div>
<div class="list-group-item" title="Best market price in USD">
<div class="row">
<div class="col-xs-6"><i class="fa fa-usd"></i> Price In USD</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInUsd <i class="fa fa-usd"></i></div>
<div class="list-group-item" title="Best market price in USD">
<div class="row">
<div class="col-xs-6"><i class="fa fa-usd"></i> Price In USD</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInUsd <i class="fa fa-usd"></i></div>
</div>
</div>
</div>
<div class="list-group-item" title="Estimated profitability in BTC per Mh / Day">
<div class="row">
<div class="col-xs-6"><i class="fa fa-btc"></i> Profitability</div>
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.BtcPerMhPerHour) <i class="fa fa-btc"></i> / hour</div>
</div>
</div>
<div class="list-group-item" title="Estimated profitability in USD per MH / Day">
<div class="row">
<div class="col-xs-6"><i class="fa fa-usd"></i> Profitability</div>
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.UsdPerMhPerHour) <i class="fa fa-usd"></i> / hour</div>
</div>
</div>
}
else
{
@:
<div class="list-group-item">
<div class="row">
<div class="col-xs-12">
Sorry, market & profitability data for @Model.Pool.Config.Coin.Name is not available.
</div>
</div>
</div>
}
<div class="list-group-item" title="Estimated number of hourly blocks (Mh / Hour)">
<div class="row">
<div class="col-xs-6"><i class="fa fa-cubes"></i> Hourly Blocks</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.BtcPerMhPerHour</div>
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.BlocksPerMhPerHour)</div>
</div>
</div>
<div class="list-group-item" title="Estimated number of hourly @Model.Pool.Config.Coin.Symbol's (Mh / Hour)">
<div class="row">
<div class="col-xs-6"><i class="fa fa-bars"></i> Hourly @Model.Pool.Config.Coin.Symbol's</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.CoinsPerMhPerHour</div>
</div>
</div>
<div class="list-group-item" title="Estimated profitability in BTC per Mh / Day">
<div class="row">
<div class="col-xs-6"><i class="fa fa-btc"></i> Profitability</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.BtcPerMhPerDay <i class="fa fa-btc"></i></div>
</div>
</div>
<div class="list-group-item" title="Estimated profitability in USD per MH / Day">
<div class="row">
<div class="col-xs-6"><i class="fa fa-usd"></i> Profitability</div>
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.UsdPerMhPerDay <i class="fa fa-usd"></i></div>
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.CoinsPerMhPerHour)</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 88e0141

Please sign in to comment.