Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Dev (#126)
Browse files Browse the repository at this point in the history
* Log block height for balance changes

* Fix share traversal

* Log one address per line
  • Loading branch information
Oliver Weichhold authored Dec 19, 2017
1 parent b46c32c commit 321ac0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/MiningCore/Payments/PayoutManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ await cf.RunTxAsync(async (con, tx) =>
}

else
logger.Info(() => $"No updated blocks for {pool.Id}");
logger.Info(() => $"No updated blocks for pool {pool.Id}");
}

private async Task PayoutPoolBalancesAsync(PoolConfig pool, IPayoutHandler handler)
Expand Down
24 changes: 12 additions & 12 deletions src/MiningCore/Payments/PayoutSchemes/PayPerLastNShares.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public Task UpdateBalancesAsync(IDbConnection con, IDbTransaction tx, PoolConfig

if (amount > 0)
{
logger.Info(() => $"Adding {payoutHandler.FormatAmount(amount)} to balance of {address} for {FormatUtil.FormatQuantity(shares[address])} ({shares[address]}) shares");
logger.Info(() => $"Adding {payoutHandler.FormatAmount(amount)} to balance of {address} for {FormatUtil.FormatQuantity(shares[address])} ({shares[address]}) shares for block {block.BlockHeight}");
balanceRepo.AddAmount(con, tx, poolConfig.Id, poolConfig.Coin.Type, address, amount);
}
}
Expand All @@ -111,7 +111,7 @@ public Task UpdateBalancesAsync(IDbConnection con, IDbTransaction tx, PoolConfig

if (cutOffCount > 0)
{
//LogObsoleteShares(poolConfig, block, shareCutOffDate.Value);
LogObsoleteShares(poolConfig, block, shareCutOffDate.Value);

logger.Info(() => $"Deleting {cutOffCount} obsolete shares before {shareCutOffDate.Value}");
shareRepo.DeletePoolSharesBeforeCreated(con, tx, poolConfig.Id, shareCutOffDate.Value);
Expand Down Expand Up @@ -144,10 +144,12 @@ private void LogObsoleteShares(PoolConfig poolConfig, Block block, DateTime valu
var blockPage = shareReadFaultPolicy.Execute(() =>
cf.Run(con => shareRepo.ReadSharesBeforeCreated(con, poolConfig.Id, before, false, pageSize)));

if (blockPage.Length == 0)
break;

currentPage++;
var start = blockPage.Length > 0 ? blockPage.Length - 1 : -1;

for (var i = start; i >= 0; i--)
for (var i = 0;i < blockPage.Length; i++)
{
var share = blockPage[i];

Expand All @@ -166,18 +168,18 @@ private void LogObsoleteShares(PoolConfig poolConfig, Block block, DateTime valu
if (blockPage.Length < pageSize)
break;

before = blockPage[0].Created;
before = blockPage[blockPage.Length - 1].Created;
}

if (shares.Keys.Count > 0)
{
// sort addresses by shares
var addressesByShares = shares.Keys.OrderByDescending(x => shares[x]);

// compute summary
var summary = string.Join("\n", addressesByShares.Select(address => $"{address} = {FormatUtil.FormatQuantity(shares[address])} ({shares[address]}) shares"));
logger.Info(() => $"{FormatUtil.FormatQuantity(shares.Values.Sum())} ({shares.Values.Sum()}) obsolete shares total for block {block.BlockHeight}");

logger.Info(() => $"{FormatUtil.FormatQuantity(shares.Values.Sum())} ({shares.Values.Sum()}) obsolete shares:\n" + summary);
foreach (var address in addressesByShares)
logger.Info(() => $"{address} = {FormatUtil.FormatQuantity(shares[address])} ({shares[address]}) shares for block {block.BlockHeight}");
}
}

Expand Down Expand Up @@ -209,9 +211,7 @@ private void LogObsoleteShares(PoolConfig poolConfig, Block block, DateTime valu
inclusive = false;
currentPage++;

var start = blockPage.Length > 0 ? blockPage.Length - 1 : -1;

for (var i = start; !done && i >= 0; i--)
for (var i = 0; !done && i < blockPage.Length; i++)
{
var share = blockPage[i];

Expand Down Expand Up @@ -258,7 +258,7 @@ private void LogObsoleteShares(PoolConfig poolConfig, Block block, DateTime valu
if (blockPage.Length < pageSize)
break;

before = blockPage[0].Created;
before = blockPage[blockPage.Length - 1].Created;
}

logger.Info(() => $"Balance-calculation for pool {poolConfig.Id}, block {block.BlockHeight} completed with accumulated score {accumulatedScore:0.####} ({(accumulatedScore / window) * 100:0.#}%)");
Expand Down

0 comments on commit 321ac0e

Please sign in to comment.