Skip to content

Commit

Permalink
Merge pull request #14 from GetBlok-io/develop
Browse files Browse the repository at this point in the history
Make copies of ports to print
  • Loading branch information
K-Singh authored Dec 2, 2021
2 parents 087169f + 8bd94cd commit 740900f
Showing 1 changed file with 52 additions and 10 deletions.
62 changes: 52 additions & 10 deletions src/Miningcore/Api/Controllers/PoolApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Miningcore.Time;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -92,22 +93,40 @@ public async Task<GetPoolsResponse> Get()
result.PoolEffort = 0;
}
result.PaymentProcessing.Extra = null;
foreach(PoolEndpoint poolEP in result.Ports.Values)
// Copy ports to hide info without changing Config
Dictionary<int, PoolEndpoint> portsCopy = new Dictionary<int, PoolEndpoint>();
foreach(int key in result.Ports.Keys)
{
if(poolEP.Tls == true || poolEP.Tls == false)
PoolEndpoint poolEP = result.Ports[key];

var newPoolEP = new PoolEndpoint
{
poolEP.Tls = false;
Name = poolEP.Name,
VarDiff = poolEP.VarDiff,
TlsPfxPassword = poolEP.TlsPfxPassword,
TlsPfxFile = poolEP.TlsPfxFile,
ListenAddress = poolEP.ListenAddress,
Tls = poolEP.Tls,
TcpProxyProtocol = poolEP.TcpProxyProtocol,
Difficulty = poolEP.Difficulty,

};

if(newPoolEP.Tls == true || newPoolEP.Tls == false)
{
newPoolEP.Tls = false;
}
if(!String.IsNullOrEmpty(poolEP.TlsPfxFile))
{
poolEP.TlsPfxFile = null;
newPoolEP.TlsPfxFile = null;
}
if(!String.IsNullOrEmpty(poolEP.TlsPfxPassword))
{
poolEP.TlsPfxPassword = null;
newPoolEP.TlsPfxPassword = null;
}
portsCopy.Add(key, newPoolEP);
}

result.Ports = portsCopy;
//result.RoundShares =
var from = clock.Now.AddDays(-1);

Expand Down Expand Up @@ -183,17 +202,40 @@ public async Task<GetPoolResponse> GetPoolInfoAsync(string poolId)
response.Pool.PoolEffort = 0;
}
response.Pool.PaymentProcessing.Extra = null;
foreach(PoolEndpoint poolEP in response.Pool.Ports.Values)
// Copy ports to hide info without changing Config
Dictionary<int, PoolEndpoint> portsCopy = new Dictionary<int, PoolEndpoint>();
foreach(int key in response.Pool.Ports.Keys)
{
if(poolEP.Tls == true || poolEP.Tls == false)
PoolEndpoint poolEP = response.Pool.Ports[key];

var newPoolEP = new PoolEndpoint
{
poolEP.Tls = false;
Name = poolEP.Name,
VarDiff = poolEP.VarDiff,
TlsPfxPassword = poolEP.TlsPfxPassword,
TlsPfxFile = poolEP.TlsPfxFile,
ListenAddress = poolEP.ListenAddress,
Tls = poolEP.Tls,
TcpProxyProtocol = poolEP.TcpProxyProtocol,
Difficulty = poolEP.Difficulty,

};

if(newPoolEP.Tls == true || newPoolEP.Tls == false)
{
newPoolEP.Tls = false;
}
if(!String.IsNullOrEmpty(poolEP.TlsPfxFile))
{
poolEP.TlsPfxFile = null;
newPoolEP.TlsPfxFile = null;
}
if(!String.IsNullOrEmpty(poolEP.TlsPfxPassword))
{
newPoolEP.TlsPfxPassword = null;
}
portsCopy.Add(key, newPoolEP);
}
response.Pool.Ports = portsCopy;
var from = clock.Now.AddDays(-1);

response.Pool.TopMiners = (await cf.Run(con => statsRepo.PagePoolMinersByHashrateAsync(
Expand Down

0 comments on commit 740900f

Please sign in to comment.