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

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Weichhold committed Mar 10, 2018
1 parent 5020e2f commit 809928a
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions src/MiningCore/Blockchain/Monero/MoneroPayoutHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,48 @@ private async Task PayoutBatch(Balance[] balances)

var transferSplitResponse = await walletDaemon.ExecuteCmdSingleAsync<TransferSplitResponse>(MWC.TransferSplit, request);

HandleTransferResponse(transferSplitResponse, balances);
return;
if (transferResponse.Error == null)
{
HandleTransferResponse(transferSplitResponse, balances);
return;
}
}

// retry paged - unfortunately this is necessary for cases like this: https://github.com/monero-project/monero/issues/3379
logger.Info(() => $"[{LogCategory}] Retrying paged");

var validBalances = balances.Where(x => x.Amount > 0).ToArray();
var pageSize = 10;
var pageCount = (int)Math.Ceiling((double)validBalances.Length / pageSize);

for (var i = 0; i < pageCount; i++)
{
var page = validBalances
.Skip(i * pageSize)
.Take(pageSize)
.ToArray();

// update request
request.Destinations = page
.Where(x => x.Amount > 0)
.Select(x =>
{
ExtractAddressAndPaymentId(x.Address, out var address, out var paymentId);

return new TransferDestination
{
Address = address,
Amount = (ulong)Math.Floor(x.Amount * MoneroConstants.SmallestUnit[poolConfig.Coin.Type])
};
}).ToArray();

logger.Info(() => $"[{LogCategory}] Page {i + 1}: Paying out {FormatAmount(page.Sum(x => x.Amount))} to {page.Length} addresses");

transferResponse = await walletDaemon.ExecuteCmdSingleAsync<TransferResponse>(MWC.Transfer, request);
HandleTransferResponse(transferResponse, balances);

if (transferResponse.Error != null)
return;
}
}

Expand Down

0 comments on commit 809928a

Please sign in to comment.