|
@@ -372,7 +372,6 @@ namespace EthermineBotTelegram
|
|
|
chatId: e,
|
|
|
text: "An exception occurred while executing this command.");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public static async Task UpdateData()
|
|
@@ -409,6 +408,15 @@ namespace EthermineBotTelegram
|
|
|
Botdb.miners.Add(newMinerRecord);
|
|
|
//await Botdb.SaveChangesAsync();
|
|
|
await Console.Out.WriteLineAsync($"Added new row for {newMinerRecord.wallet}");
|
|
|
+
|
|
|
+ if (newMinerRecord.unpaid < lastMinerRecord.unpaid)
|
|
|
+ {
|
|
|
+ await botClient.SendTextMessageAsync(
|
|
|
+ chatId: Botdb.users.Where(user => user.wallet == newMinerRecord.wallet)
|
|
|
+ .FirstOrDefault().chat_id,
|
|
|
+ text: "Payout detected!");
|
|
|
+ }
|
|
|
+
|
|
|
url = AppSettings.poolApiUrl + "/miner/" + u.wallet + "/workers";
|
|
|
var currentWorker = JsonDownloader._download_serialized_json_data<JsonWorker>(url);
|
|
|
|
|
@@ -442,14 +450,33 @@ namespace EthermineBotTelegram
|
|
|
//check for payout
|
|
|
if (newMinerRecord.unpaid < lastMinerRecord.unpaid)
|
|
|
{
|
|
|
- await botClient.SendTextMessageAsync(
|
|
|
- chatId: Botdb.users.Where(user=>user.wallet == newMinerRecord.wallet).FirstOrDefault().chat_id,
|
|
|
- text: "Payout detected!");
|
|
|
-
|
|
|
url = AppSettings.poolApiUrl + "/miner/" + u.wallet + "/payouts";
|
|
|
var payouts = JsonDownloader._download_serialized_json_data<JsonPayouts>(url);
|
|
|
|
|
|
await Console.Out.WriteLineAsync($"Last payout time = {DateTimeOffset.FromUnixTimeSeconds(payouts.data[0].paidOn).LocalDateTime.ToString("f")}");
|
|
|
+
|
|
|
+ var newPayoutRecord = new payouts();
|
|
|
+ newPayoutRecord.wallet = u.wallet;
|
|
|
+ newPayoutRecord.time = payouts.data[0].paidOn;
|
|
|
+ newPayoutRecord.amount = payouts.data[0].amount;
|
|
|
+ newPayoutRecord.worker = newWorkerRecord.worker;
|
|
|
+ //calculating payout for worker
|
|
|
+ newPayoutRecord.worker_amount = lastWorkerRecord.worker_unpaid +
|
|
|
+ (payouts.data[0].amount -
|
|
|
+ lastMinerRecord.unpaid) *
|
|
|
+ (newWorkerRecord.reported_hashrate /
|
|
|
+ ((double) newMinerRecord.reported_hashrate));
|
|
|
+ if (Double.IsNaN(newWorkerRecord.worker_unpaid) ||
|
|
|
+ Double.IsInfinity(newWorkerRecord.worker_unpaid))
|
|
|
+ newPayoutRecord.worker_amount = lastWorkerRecord.worker_unpaid;
|
|
|
+ //calculating unpaid for worker
|
|
|
+ newWorkerRecord.worker_unpaid = 0 +
|
|
|
+ (newMinerRecord.unpaid) *
|
|
|
+ (newWorkerRecord.reported_hashrate /
|
|
|
+ ((double) newMinerRecord.reported_hashrate));
|
|
|
+ if (Double.IsNaN(newWorkerRecord.worker_unpaid) ||
|
|
|
+ Double.IsInfinity(newWorkerRecord.worker_unpaid))
|
|
|
+ newWorkerRecord.worker_unpaid = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -494,7 +521,7 @@ namespace EthermineBotTelegram
|
|
|
{
|
|
|
await Console.Out.WriteLineAsync($"Row with wallet: {newMinerRecord.wallet} and time: {newMinerRecord.time} already exists!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
await Botdb.SaveChangesAsync();
|
|
@@ -504,21 +531,17 @@ namespace EthermineBotTelegram
|
|
|
{
|
|
|
await Console.Out.WriteLineAsync(exception.Message);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
await Console.Out.WriteLineAsync($"Error response from pool for {u.wallet}!");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
catch (Exception exception)
|
|
|
{
|
|
|
await Console.Out.WriteLineAsync(exception.Message);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
static async Task SendCalcTime(MessageEventArgs e)
|