Skip to content

Commit 88e0141

Browse files
author
Hüseyin Uslu
committed
Merge pull request #645 from CoiniumServ/develop
updates
2 parents 9973e17 + 1ee4bd0 commit 88e0141

File tree

8 files changed

+79
-68
lines changed

8 files changed

+79
-68
lines changed

Changelog.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
**Features**
44
* Implemented basic market data support initially from Cryptsy, Bittrex and Poloniex.
5+
6+
**Improvements**
7+
* Marked miner connection, disconnection, share-submission log messages as debug level, so server.log file by default doesn't get spammed with them.
8+
* Improved exception handlers for daemon connections.
59

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

1115
**Web**
1216
* Added robots.txt

src/CoiniumServ/Mining/MinerManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void Authenticate(IMiner miner)
141141
// if username validation is not on just authenticate the miner, else ask the current storage layer to do so.
142142
miner.Authenticated = !_poolConfig.Miner.ValidateUsername || _storageLayer.Authenticate(miner);
143143

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

src/CoiniumServ/Payments/PaymentProcessor.cs

+19-15
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,32 @@ private IEnumerable<KeyValuePair<string, List<ITransaction>>> GetTransactionCand
9494

9595
foreach (var payment in pendingPayments)
9696
{
97-
// query the user for the payment.
98-
var user = _accountManager.GetAccountById(payment.AccountId);
97+
try {
98+
// query the user for the payment.
99+
var user = _accountManager.GetAccountById(payment.AccountId);
99100

100-
if (user == null)
101-
continue;
101+
if (user == null) // if the user doesn't exist
102+
continue; // just skip.
102103

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

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

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

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

115-
perUserTransactions.Add(user.Username, new List<ITransaction>());
116-
}
116+
perUserTransactions.Add(user.Username, new List<ITransaction>());
117+
}
117118

118-
perUserTransactions[user.Username].Add(new Transaction(user, payment, _poolConfig.Coin.Symbol)); // add the payment to user.
119+
perUserTransactions[user.Username].Add(new Transaction(user, payment, _poolConfig.Coin.Symbol)); // add the payment to user.
120+
}
121+
catch(RpcException)
122+
{ } // on rpc exception; just skip the payment for now.
119123
}
120124

121125
return perUserTransactions;

src/CoiniumServ/Pools/IProfitInfo.cs

-6
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ public interface IProfitInfo
4343
[JsonProperty("btcPerMhPerHour")]
4444
double BtcPerMhPerHour { get; }
4545

46-
[JsonProperty("btcPerMhPerDay")]
47-
double BtcPerMhPerDay { get; }
48-
4946
[JsonProperty("usdPerMhPerHour")]
5047
double UsdPerMhPerHour { get; }
51-
52-
[JsonProperty("usdPerMhPerDay")]
53-
double UsdPerMhPerDay { get; }
5448
}
5549
}

src/CoiniumServ/Pools/ProfitInfo.cs

-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public class ProfitInfo : IProfitInfo
4646
public double CoinsPerMhPerHour { get; private set; }
4747

4848
public double BtcPerMhPerHour { get; private set; }
49-
public double BtcPerMhPerDay { get; private set; }
5049

5150
public double UsdPerMhPerHour { get; private set; }
52-
public double UsdPerMhPerDay { get; private set; }
5351

5452
public ProfitInfo(IMarketManager marketManager, INetworkInfo networkInfo, IPoolConfig poolConfig)
5553
{
@@ -88,9 +86,7 @@ private void CalculateProfitability()
8886
BlocksPerMhPerHour = interval / ((_networkInfo.Difficulty * Math.Pow(2, 32)) / hashrate);
8987
CoinsPerMhPerHour = BlocksPerMhPerHour*_networkInfo.Reward;
9088
BtcPerMhPerHour = CoinsPerMhPerHour*Convert.ToDouble(PriceInBtc);
91-
BtcPerMhPerDay = BtcPerMhPerHour*24;
9289
UsdPerMhPerHour = CoinsPerMhPerHour*Convert.ToDouble(PriceInUsd);
93-
UsdPerMhPerDay = UsdPerMhPerHour*24;
9490
}
9591
}
9692
}

src/CoiniumServ/Server/Mining/Stratum/StratumServer.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public override bool IsBanned(Socket socket)
124124
/// <param name="e"></param>
125125
private void OnClientConnection(object sender, ConnectionEventArgs e)
126126
{
127-
_logger.Information("Stratum client connected: {0}", e.Connection.ToString());
127+
_logger.Debug("Stratum client connected: {0}", e.Connection.ToString());
128128

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

143143
_minerManager.Remove(e.Connection);
144144
}
145145

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

151151
/// <summary>

src/CoiniumServ/web/default/views/partial/pools.cshtml

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@using System
2-
@using System.Linq
1+
@using System.Linq
32
@using CoiniumServ.Utils.Helpers
43
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<System.Collections.Generic.IEnumerable<CoiniumServ.Pools.IPool>>
54

@@ -17,15 +16,15 @@
1716
<thead>
1817
<tr>
1918
<th class="hidden-xs" style="width: 40px;"></th>
20-
<th>Pool</th>
21-
<th>Hashrate</th>
22-
<th>Network</th>
23-
<th>Difficulty</th>
24-
<th class="hidden-xs">Profitability (BTC/Mh/Day)</th>
25-
<th class="hidden-xs">Workers</th>
26-
<th class="hidden-xs">Algorithm</th>
27-
<th class="hidden-xs">Last Block</th>
28-
<th class="hidden-xs">Status</th>
19+
<th title="Pool's name">Pool</th>
20+
<th title="Total hashrate of the pool">Hashrate</th>
21+
<th title="Total hashrate of the network">Network</th>
22+
<th title="Difficulty of the network">Difficulty</th>
23+
<th class="hidden-xs" title="Profitability of pool in USD for 1 MH/s per hour">Profitability</th>
24+
<th class="hidden-xs" title="Number of connected workers">Workers</th>
25+
<th class="hidden-xs" title="The algorithm used by the pool">Algorithm</th>
26+
<th class="hidden-xs" title="Time of the last found block">Last Block</th>
27+
<th class="hidden-xs" title="Status of the pool">Status</th>
2928
</tr>
3029
</thead>
3130
<tbody>
@@ -37,14 +36,14 @@
3736
<td>@pool.Hashrate.GetReadableHashrate()</td>
3837
<td>@pool.NetworkInfo.Hashrate.GetReadableHashrate()</td>
3938
<td title="@string.Format("{0:n8}",pool.NetworkInfo.Difficulty)">@pool.NetworkInfo.Difficulty.GetReadableDifficulty()</td>
40-
<td>@pool.ProfitInfo.BtcPerMhPerDay</td>
39+
<td>@(pool.ProfitInfo.UsdPerMhPerHour > 0 ? string.Format("{0:n2} $/hour", pool.ProfitInfo.UsdPerMhPerHour) : "N/A")</td>
4140
<td class="hidden-xs">@pool.MinerManager.Count</td>
4241
<td class="hidden-xs"><a href="/algorithm/@pool.Config.Coin.Algorithm">@pool.Config.Coin.Algorithm</a></td>
4342
<td class="hidden-xs">
4443
@{
45-
var lastBlock = pool.BlockRepository.Latest.Count > 0 ? pool.BlockRepository.Latest.First().CreatedAt.ToString("yyyy-MM-ddTHH:mm:ssZ") : "N/A";
44+
var lastBlock = pool.BlockRepository.Latest.Count > 0 ? pool.BlockRepository.Latest.First().CreatedAt.ToString("yyyy-MM-ddTHH:mm:ssZ") : "N/A";
4645
<time class="timeago" datetime="@lastBlock">@lastBlock</time>
47-
}
46+
}
4847
</td>
4948
<td class="hidden-xs">
5049
<div class="label @(pool.NetworkInfo.Healthy? "label-info" : "label-danger")">@(pool.NetworkInfo.Healthy ? "Healthy" : "Warnings!")</div>

src/CoiniumServ/web/default/views/pool/pool.cshtml

+38-24
Original file line numberDiff line numberDiff line change
@@ -317,40 +317,54 @@
317317
</div>
318318
<div class="box-body no-padding">
319319
<div class="list-group">
320-
<div class="list-group-item" title="Best market price in BTC">
321-
<div class="row">
322-
<div class="col-xs-6"><i class="fa fa-btc"></i> Price In BTC</div>
323-
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInBtc <i class="fa fa-btc"></i></div>
320+
@if (Model.Pool.ProfitInfo.PriceInBtc > 0)
321+
{
322+
<div class="list-group-item" title="Best market price in BTC">
323+
<div class="row">
324+
<div class="col-xs-6"><i class="fa fa-btc"></i> Price In BTC</div>
325+
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInBtc <i class="fa fa-btc"></i></div>
326+
</div>
324327
</div>
325-
</div>
326-
<div class="list-group-item" title="Best market price in USD">
327-
<div class="row">
328-
<div class="col-xs-6"><i class="fa fa-usd"></i> Price In USD</div>
329-
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInUsd <i class="fa fa-usd"></i></div>
328+
<div class="list-group-item" title="Best market price in USD">
329+
<div class="row">
330+
<div class="col-xs-6"><i class="fa fa-usd"></i> Price In USD</div>
331+
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.PriceInUsd <i class="fa fa-usd"></i></div>
332+
</div>
330333
</div>
331-
</div>
334+
<div class="list-group-item" title="Estimated profitability in BTC per Mh / Day">
335+
<div class="row">
336+
<div class="col-xs-6"><i class="fa fa-btc"></i> Profitability</div>
337+
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.BtcPerMhPerHour) <i class="fa fa-btc"></i> / hour</div>
338+
</div>
339+
</div>
340+
<div class="list-group-item" title="Estimated profitability in USD per MH / Day">
341+
<div class="row">
342+
<div class="col-xs-6"><i class="fa fa-usd"></i> Profitability</div>
343+
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.UsdPerMhPerHour) <i class="fa fa-usd"></i> / hour</div>
344+
</div>
345+
</div>
346+
}
347+
else
348+
{
349+
@:
350+
<div class="list-group-item">
351+
<div class="row">
352+
<div class="col-xs-12">
353+
Sorry, market & profitability data for @Model.Pool.Config.Coin.Name is not available.
354+
</div>
355+
</div>
356+
</div>
357+
}
332358
<div class="list-group-item" title="Estimated number of hourly blocks (Mh / Hour)">
333359
<div class="row">
334360
<div class="col-xs-6"><i class="fa fa-cubes"></i> Hourly Blocks</div>
335-
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.BtcPerMhPerHour</div>
361+
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.BlocksPerMhPerHour)</div>
336362
</div>
337363
</div>
338364
<div class="list-group-item" title="Estimated number of hourly @Model.Pool.Config.Coin.Symbol's (Mh / Hour)">
339365
<div class="row">
340366
<div class="col-xs-6"><i class="fa fa-bars"></i> Hourly @Model.Pool.Config.Coin.Symbol's</div>
341-
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.CoinsPerMhPerHour</div>
342-
</div>
343-
</div>
344-
<div class="list-group-item" title="Estimated profitability in BTC per Mh / Day">
345-
<div class="row">
346-
<div class="col-xs-6"><i class="fa fa-btc"></i> Profitability</div>
347-
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.BtcPerMhPerDay <i class="fa fa-btc"></i></div>
348-
</div>
349-
</div>
350-
<div class="list-group-item" title="Estimated profitability in USD per MH / Day">
351-
<div class="row">
352-
<div class="col-xs-6"><i class="fa fa-usd"></i> Profitability</div>
353-
<div class="col-xs-6 text-right">@Model.Pool.ProfitInfo.UsdPerMhPerDay <i class="fa fa-usd"></i></div>
367+
<div class="col-xs-6 text-right">@string.Format("{0:n2}", Model.Pool.ProfitInfo.CoinsPerMhPerHour)</div>
354368
</div>
355369
</div>
356370
</div>

0 commit comments

Comments
 (0)