Removes waitForSubmitted from RequestStorage call.

This commit is contained in:
ThatBen 2025-03-03 15:56:52 +01:00
parent 789852bf1a
commit f58a42a1ca
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
3 changed files with 7 additions and 8 deletions

View File

@ -46,12 +46,7 @@ namespace CodexClient
Log($"Storage requested successfully. PurchaseId: '{response}'.");
var contract = new StoragePurchaseContract(log, codexAccess, response, purchase, hooks);
contract.WaitForStorageContractSubmitted();
hooks.OnStorageContractSubmitted(contract);
return contract;
return new StoragePurchaseContract(log, codexAccess, response, purchase, hooks);
}
public string MakeStorageAvailable(StorageAvailability availability)

View File

@ -28,6 +28,7 @@ namespace CodexClient
private DateTime? contractSubmittedUtc = DateTime.UtcNow;
private DateTime? contractStartedUtc;
private DateTime? contractFinishedUtc;
private string lastState = string.Empty;
public StoragePurchaseContract(ILog log, CodexAccess codexAccess, string purchaseId, StoragePurchaseRequest purchase, ICodexNodeHooks hooks)
{
@ -54,8 +55,10 @@ namespace CodexClient
public void WaitForStorageContractSubmitted()
{
var raiseHook = lastState != "submitted";
WaitForStorageContractState(gracePeriod, "submitted", sleep: 200);
contractSubmittedUtc = DateTime.UtcNow;
if (raiseHook) hooks.OnStorageContractSubmitted(this);
LogSubmittedDuration();
AssertDuration(PendingToSubmitted, gracePeriod, nameof(PendingToSubmitted));
}
@ -102,7 +105,6 @@ namespace CodexClient
private void WaitForStorageContractState(TimeSpan timeout, string desiredState, int sleep = 1000)
{
var lastState = "";
var waitStart = DateTime.UtcNow;
Log($"Waiting for {Time.FormatDuration(timeout)} to reach state '{desiredState}'.");

View File

@ -158,6 +158,9 @@ namespace AutoClient.Modes.FolderStore
WaitForSubmitted(request);
WaitForStarted(request);
stats.StorageRequestStats.SuccessfullyStarted++;
saveChanges();
Log($"Successfully started new purchase: '{entry.PurchaseId}' for {Time.FormatDuration(request.Purchase.Duration)}");
}
catch (Exception exc)
@ -178,7 +181,6 @@ namespace AutoClient.Modes.FolderStore
entry.EncodedCid = request.Purchase.ContentId.Id;
entry.PurchaseId = request.PurchaseId;
entry.PurchaseFinishedUtc = DateTime.UtcNow + request.Purchase.Duration;
stats.StorageRequestStats.SuccessfullyStarted++;
saveChanges();
Log("Saved new purchaseId: " + entry.PurchaseId);
return request;