Restore Monero paged payout retries
@@ -163,7 +163,9 @@ namespace MiningCore.Blockchain.Monero
var transferResponse = await walletDaemon.ExecuteCmdSingleAsync<TransferResponse>(MWC.Transfer, request);
// gracefully handle error -4 (transaction would be too large. try /transfer_split)
- if (transferResponse.Error?.Code == -4 && walletSupportsTransferSplit)
+ if (transferResponse.Error?.Code == -4)
+ {
+ if (walletSupportsTransferSplit)
{
logger.Info(() => $"[{LogCategory}] Retrying transfer using {MWC.TransferSplit}");
@@ -177,6 +179,45 @@ namespace MiningCore.Blockchain.Monero
}
}
+ // retry paged
+ 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, page);
+
+ if (transferResponse.Error != null)
+ break;
+ }
+ }
+
+ else
HandleTransferResponse(transferResponse, balances);
}
