Skip to content

Commit 582c732

Browse files
committed
Fixes api mismatch in purchase status check
1 parent 83e4cb2 commit 582c732

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Framework/Utils/Retry.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ private Failure CaptureFailure(Exception ex)
9494
private void CheckMaximums()
9595
{
9696
if (Duration() > maxTimeout) Fail();
97+
98+
// If we have a few very fast failures, retrying won't help us. There's probably something wrong with our operation.
99+
// In this case, don't wait the full duration and fail quickly.
100+
if (failures.Count > 5 && failures.All(f => f.Duration < TimeSpan.FromSeconds(1.0))) Fail();
97101
}
98102

99103
private void Fail()

ProjectPlugins/CodexClient/Mapper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public StorageRequest Map(CodexOpenApi.StorageRequest request)
128128
Content = Map(request.Content),
129129
Id = request.Id,
130130
Client = request.Client,
131-
Expiry = TimeSpan.FromSeconds(request.Expiry),
131+
Expiry = request.Expiry,
132132
Nonce = request.Nonce
133133
};
134134
}
@@ -137,12 +137,12 @@ public StorageAsk Map(CodexOpenApi.StorageAsk ask)
137137
{
138138
return new StorageAsk
139139
{
140-
Duration = TimeSpan.FromSeconds(ask.Duration),
140+
Duration = ask.Duration,
141141
MaxSlotLoss = ask.MaxSlotLoss,
142142
ProofProbability = ask.ProofProbability,
143-
PricePerBytePerSecond = ToTestToken(ask.PricePerBytePerSecond),
143+
PricePerBytePerSecond = ask.PricePerBytePerSecond,
144144
Slots = ask.Slots,
145-
SlotSize = ToByteSize(ask.SlotSize)
145+
SlotSize = ask.SlotSize
146146
};
147147
}
148148

ProjectPlugins/CodexClient/MarketplaceTypes.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ public class StorageRequest
6363
public string Client { get; set; } = string.Empty;
6464
public StorageAsk Ask { get; set; } = null!;
6565
public StorageContent Content { get; set; } = null!;
66-
public TimeSpan Expiry { get; set; }
66+
public long Expiry { get; set; }
6767
public string Nonce { get; set; } = string.Empty;
6868
}
6969

7070
public class StorageAsk
7171
{
7272
public long Slots { get; set; }
73-
public ByteSize SlotSize { get; set; } = 0.Bytes();
74-
public TimeSpan Duration { get; set; }
73+
public long SlotSize { get; set; }
74+
public long Duration { get; set; }
7575
public string ProofProbability { get; set; } = string.Empty;
76-
public TestToken PricePerBytePerSecond { get; set; } = 0.Tst();
76+
public string PricePerBytePerSecond { get; set; } = string.Empty;
7777
public long MaxSlotLoss { get; set; }
7878
}
7979

0 commit comments

Comments
 (0)