Fixes api mismatch in purchase status check

This commit is contained in:
ThatBen 2025-04-03 10:45:09 +02:00
parent 83e4cb2e04
commit 582c7326a1
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
3 changed files with 12 additions and 8 deletions

View File

@ -94,6 +94,10 @@
private void CheckMaximums()
{
if (Duration() > maxTimeout) Fail();
// If we have a few very fast failures, retrying won't help us. There's probably something wrong with our operation.
// In this case, don't wait the full duration and fail quickly.
if (failures.Count > 5 && failures.All(f => f.Duration < TimeSpan.FromSeconds(1.0))) Fail();
}
private void Fail()

View File

@ -128,7 +128,7 @@ namespace CodexClient
Content = Map(request.Content),
Id = request.Id,
Client = request.Client,
Expiry = TimeSpan.FromSeconds(request.Expiry),
Expiry = request.Expiry,
Nonce = request.Nonce
};
}
@ -137,12 +137,12 @@ namespace CodexClient
{
return new StorageAsk
{
Duration = TimeSpan.FromSeconds(ask.Duration),
Duration = ask.Duration,
MaxSlotLoss = ask.MaxSlotLoss,
ProofProbability = ask.ProofProbability,
PricePerBytePerSecond = ToTestToken(ask.PricePerBytePerSecond),
PricePerBytePerSecond = ask.PricePerBytePerSecond,
Slots = ask.Slots,
SlotSize = ToByteSize(ask.SlotSize)
SlotSize = ask.SlotSize
};
}

View File

@ -63,17 +63,17 @@ namespace CodexClient
public string Client { get; set; } = string.Empty;
public StorageAsk Ask { get; set; } = null!;
public StorageContent Content { get; set; } = null!;
public TimeSpan Expiry { get; set; }
public long Expiry { get; set; }
public string Nonce { get; set; } = string.Empty;
}
public class StorageAsk
{
public long Slots { get; set; }
public ByteSize SlotSize { get; set; } = 0.Bytes();
public TimeSpan Duration { get; set; }
public long SlotSize { get; set; }
public long Duration { get; set; }
public string ProofProbability { get; set; } = string.Empty;
public TestToken PricePerBytePerSecond { get; set; } = 0.Tst();
public string PricePerBytePerSecond { get; set; } = string.Empty;
public long MaxSlotLoss { get; set; }
}