From 7b85cc12a9b2bf25407661bd41231aa75f5fd686 Mon Sep 17 00:00:00 2001 From: bonesoul Date: Mon, 27 Oct 2014 15:08:48 +0200 Subject: [PATCH 1/2] Marked miner connection, disconnection, share-submission log messages as debug level, so server.log file by default doesn't get spammed with them. Fixed a bug in PaymentProcessor.cs which was causing crashes for invalid addresses, fixes #569. Improved rendering of profitability data in web front-end. --- src/CoiniumServ/Mining/MinerManager.cs | 2 +- src/CoiniumServ/Payments/PaymentProcessor.cs | 34 +++++----- src/CoiniumServ/Pools/IProfitInfo.cs | 6 -- src/CoiniumServ/Pools/ProfitInfo.cs | 4 -- .../Server/Mining/Stratum/StratumServer.cs | 6 +- .../web/default/views/partial/pools.cshtml | 27 ++++---- .../web/default/views/pool/pool.cshtml | 62 ++++++++++++------- 7 files changed, 74 insertions(+), 67 deletions(-) diff --git a/src/CoiniumServ/Mining/MinerManager.cs b/src/CoiniumServ/Mining/MinerManager.cs index fd4b1c5c9..b25a0fa3b 100644 --- a/src/CoiniumServ/Mining/MinerManager.cs +++ b/src/CoiniumServ/Mining/MinerManager.cs @@ -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); diff --git a/src/CoiniumServ/Payments/PaymentProcessor.cs b/src/CoiniumServ/Payments/PaymentProcessor.cs index ca6ef90bc..b3cc4c882 100644 --- a/src/CoiniumServ/Payments/PaymentProcessor.cs +++ b/src/CoiniumServ/Payments/PaymentProcessor.cs @@ -94,28 +94,32 @@ private IEnumerable>> GetTransactionCand 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()); - } + perUserTransactions.Add(user.Username, new List()); + } - 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; diff --git a/src/CoiniumServ/Pools/IProfitInfo.cs b/src/CoiniumServ/Pools/IProfitInfo.cs index ed78e697c..708c4944d 100644 --- a/src/CoiniumServ/Pools/IProfitInfo.cs +++ b/src/CoiniumServ/Pools/IProfitInfo.cs @@ -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; } } } diff --git a/src/CoiniumServ/Pools/ProfitInfo.cs b/src/CoiniumServ/Pools/ProfitInfo.cs index 22b387c01..2ffc48a09 100644 --- a/src/CoiniumServ/Pools/ProfitInfo.cs +++ b/src/CoiniumServ/Pools/ProfitInfo.cs @@ -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) { @@ -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; } } } diff --git a/src/CoiniumServ/Server/Mining/Stratum/StratumServer.cs b/src/CoiniumServ/Server/Mining/Stratum/StratumServer.cs index cba0c15e7..7b74e03b9 100644 --- a/src/CoiniumServ/Server/Mining/Stratum/StratumServer.cs +++ b/src/CoiniumServ/Server/Mining/Stratum/StratumServer.cs @@ -124,7 +124,7 @@ public override bool IsBanned(Socket socket) /// 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(_jobManager.ExtraNonce.Next(), e.Connection, _pool); @@ -138,14 +138,14 @@ private void OnClientConnection(object sender, ConnectionEventArgs e) /// 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()); } /// diff --git a/src/CoiniumServ/web/default/views/partial/pools.cshtml b/src/CoiniumServ/web/default/views/partial/pools.cshtml index df1aaee14..b7ff3ad9d 100644 --- a/src/CoiniumServ/web/default/views/partial/pools.cshtml +++ b/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> @@ -17,15 +16,15 @@ - Pool - Hashrate - Network - Difficulty - Profitability (BTC/Mh/Day) - Workers - Algorithm - Last Block - Status + Pool + Hashrate + Network + Difficulty + Profitability + Workers + Algorithm + Last Block + Status @@ -37,14 +36,14 @@ @pool.Hashrate.GetReadableHashrate() @pool.NetworkInfo.Hashrate.GetReadableHashrate() @pool.NetworkInfo.Difficulty.GetReadableDifficulty() - @pool.ProfitInfo.BtcPerMhPerDay + @(pool.ProfitInfo.UsdPerMhPerHour > 0 ? string.Format("{0:n2} $/hour", pool.ProfitInfo.UsdPerMhPerHour) : "N/A") @pool.MinerManager.Count @pool.Config.Coin.Algorithm @{ - 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"; - } + }
@(pool.NetworkInfo.Healthy ? "Healthy" : "Warnings!")
diff --git a/src/CoiniumServ/web/default/views/pool/pool.cshtml b/src/CoiniumServ/web/default/views/pool/pool.cshtml index 85ad8436c..47a8afd1d 100644 --- a/src/CoiniumServ/web/default/views/pool/pool.cshtml +++ b/src/CoiniumServ/web/default/views/pool/pool.cshtml @@ -317,40 +317,54 @@
-
-
-
Price In BTC
-
@Model.Pool.ProfitInfo.PriceInBtc
+ @if (Model.Pool.ProfitInfo.PriceInBtc > 0) + { +
+
+
Price In BTC
+
@Model.Pool.ProfitInfo.PriceInBtc
+
-
-
-
-
Price In USD
-
@Model.Pool.ProfitInfo.PriceInUsd
+
+
+
Price In USD
+
@Model.Pool.ProfitInfo.PriceInUsd
+
-
+
+
+
Profitability
+
@string.Format("{0:n2}", Model.Pool.ProfitInfo.BtcPerMhPerHour) / hour
+
+
+
+
+
Profitability
+
@string.Format("{0:n2}", Model.Pool.ProfitInfo.UsdPerMhPerHour) / hour
+
+
+ } + else + { + @: +
+
+
+ Sorry, market & profitability data for @Model.Pool.Config.Coin.Name is not available. +
+
+
+ }
Hourly Blocks
-
@Model.Pool.ProfitInfo.BtcPerMhPerHour
+
@string.Format("{0:n2}", Model.Pool.ProfitInfo.BlocksPerMhPerHour)
Hourly @Model.Pool.Config.Coin.Symbol's
-
@Model.Pool.ProfitInfo.CoinsPerMhPerHour
-
-
-
-
-
Profitability
-
@Model.Pool.ProfitInfo.BtcPerMhPerDay
-
-
-
-
-
Profitability
-
@Model.Pool.ProfitInfo.UsdPerMhPerDay
+
@string.Format("{0:n2}", Model.Pool.ProfitInfo.CoinsPerMhPerHour)
From 9ed761099b71ef0ba0282fc8b706d8bcc15f2740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20Uslu?= Date: Mon, 27 Oct 2014 16:13:22 +0300 Subject: [PATCH 2/2] Update Changelog.md --- Changelog.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index cf0ab80b0..6d8c0ebed 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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