Better safe-duration
This commit is contained in:
parent
a40d5d77d7
commit
513853d929
|
@ -38,13 +38,9 @@ namespace AutoClient.Modes.FolderStore
|
|||
{
|
||||
try
|
||||
{
|
||||
Log($"Updating for '{sourceFilename}'...");
|
||||
if (IsCurrentlyRunning() && UpdatedRecently())
|
||||
{
|
||||
Log("Is running, was recently checked. Skip.");
|
||||
return;
|
||||
}
|
||||
if (IsCurrentlyRunning() && UpdatedRecently()) return;
|
||||
|
||||
Log($"Updating for '{sourceFilename}'...");
|
||||
var cid = await EnsureCid();
|
||||
await EnsureRecentPurchase(cid);
|
||||
SaveState();
|
||||
|
@ -62,7 +58,7 @@ namespace AutoClient.Modes.FolderStore
|
|||
private bool UpdatedRecently()
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
return State.LastUpdate + TimeSpan.FromHours(1) > now;
|
||||
return State.LastUpdate + TimeSpan.FromMinutes(15) > now;
|
||||
}
|
||||
|
||||
private async Task<string> EnsureCid()
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace AutoClient.Modes.FolderStore
|
|||
log.Log("");
|
||||
log.Log("Max number of busy workers reached. Waiting until contracts are started before creating any more.");
|
||||
log.Log("");
|
||||
Thread.Sleep(10000);
|
||||
ResetIndex();
|
||||
Thread.Sleep(TimeSpan.FromMinutes(1));
|
||||
}
|
||||
|
||||
var file = new FileIndex(files[index], index);
|
||||
|
|
|
@ -2,7 +2,17 @@
|
|||
{
|
||||
public class PurchaseInfo
|
||||
{
|
||||
public TimeSpan PurchaseDurationTotal { get; set; }
|
||||
public TimeSpan PurchaseDurationSafe { get; set; }
|
||||
public PurchaseInfo(TimeSpan purchaseDurationTotal, TimeSpan purchaseDurationSafe)
|
||||
{
|
||||
PurchaseDurationTotal = purchaseDurationTotal;
|
||||
PurchaseDurationSafe = purchaseDurationSafe;
|
||||
|
||||
if (PurchaseDurationTotal < TimeSpan.Zero) throw new Exception(nameof(PurchaseDurationTotal));
|
||||
if (PurchaseDurationSafe < TimeSpan.Zero) throw new Exception(nameof(PurchaseDurationSafe));
|
||||
if (PurchaseDurationTotal < PurchaseDurationSafe) throw new Exception("TotalDuration < SafeDuration");
|
||||
}
|
||||
|
||||
public TimeSpan PurchaseDurationTotal { get; }
|
||||
public TimeSpan PurchaseDurationSafe { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,11 +68,10 @@ public class Program
|
|||
{
|
||||
if (app.Config.ContractDurationMinutes - 1 < 5) throw new Exception("Contract duration config option not long enough!");
|
||||
|
||||
return new FolderStoreMode(app, app.Config.FolderToStore, new PurchaseInfo
|
||||
{
|
||||
PurchaseDurationTotal = TimeSpan.FromMinutes(app.Config.ContractDurationMinutes),
|
||||
PurchaseDurationSafe = TimeSpan.FromMinutes(app.Config.ContractDurationMinutes - 1),
|
||||
});
|
||||
return new FolderStoreMode(app, app.Config.FolderToStore, new PurchaseInfo(
|
||||
purchaseDurationTotal: TimeSpan.FromMinutes(app.Config.ContractDurationMinutes),
|
||||
purchaseDurationSafe: TimeSpan.FromMinutes(app.Config.ContractDurationMinutes - 120)
|
||||
));
|
||||
}
|
||||
|
||||
private async Task<CodexInstance[]> CreateCodexInstances()
|
||||
|
|
Loading…
Reference in New Issue