Skip to content

Commit f58a42a

Browse files
committed
Removes waitForSubmitted from RequestStorage call.
1 parent 789852b commit f58a42a

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

ProjectPlugins/CodexClient/MarketplaceAccess.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ public IStoragePurchaseContract RequestStorage(StoragePurchaseRequest purchase)
4646

4747
Log($"Storage requested successfully. PurchaseId: '{response}'.");
4848

49-
var contract = new StoragePurchaseContract(log, codexAccess, response, purchase, hooks);
50-
contract.WaitForStorageContractSubmitted();
51-
52-
hooks.OnStorageContractSubmitted(contract);
53-
54-
return contract;
49+
return new StoragePurchaseContract(log, codexAccess, response, purchase, hooks);
5550
}
5651

5752
public string MakeStorageAvailable(StorageAvailability availability)

ProjectPlugins/CodexClient/StoragePurchaseContract.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class StoragePurchaseContract : IStoragePurchaseContract
2828
private DateTime? contractSubmittedUtc = DateTime.UtcNow;
2929
private DateTime? contractStartedUtc;
3030
private DateTime? contractFinishedUtc;
31+
private string lastState = string.Empty;
3132

3233
public StoragePurchaseContract(ILog log, CodexAccess codexAccess, string purchaseId, StoragePurchaseRequest purchase, ICodexNodeHooks hooks)
3334
{
@@ -54,8 +55,10 @@ public StoragePurchase GetStatus()
5455

5556
public void WaitForStorageContractSubmitted()
5657
{
58+
var raiseHook = lastState != "submitted";
5759
WaitForStorageContractState(gracePeriod, "submitted", sleep: 200);
5860
contractSubmittedUtc = DateTime.UtcNow;
61+
if (raiseHook) hooks.OnStorageContractSubmitted(this);
5962
LogSubmittedDuration();
6063
AssertDuration(PendingToSubmitted, gracePeriod, nameof(PendingToSubmitted));
6164
}
@@ -102,7 +105,6 @@ public StoragePurchase GetPurchaseStatus()
102105

103106
private void WaitForStorageContractState(TimeSpan timeout, string desiredState, int sleep = 1000)
104107
{
105-
var lastState = "";
106108
var waitStart = DateTime.UtcNow;
107109

108110
Log($"Waiting for {Time.FormatDuration(timeout)} to reach state '{desiredState}'.");

Tools/AutoClient/Modes/FolderStore/FileSaver.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ private void CreateNewPurchase()
158158
WaitForSubmitted(request);
159159
WaitForStarted(request);
160160

161+
stats.StorageRequestStats.SuccessfullyStarted++;
162+
saveChanges();
163+
161164
Log($"Successfully started new purchase: '{entry.PurchaseId}' for {Time.FormatDuration(request.Purchase.Duration)}");
162165
}
163166
catch (Exception exc)
@@ -178,7 +181,6 @@ private IStoragePurchaseContract CreateNewStorageRequest()
178181
entry.EncodedCid = request.Purchase.ContentId.Id;
179182
entry.PurchaseId = request.PurchaseId;
180183
entry.PurchaseFinishedUtc = DateTime.UtcNow + request.Purchase.Duration;
181-
stats.StorageRequestStats.SuccessfullyStarted++;
182184
saveChanges();
183185
Log("Saved new purchaseId: " + entry.PurchaseId);
184186
return request;

0 commit comments

Comments
 (0)