Fixes request-storage endpoint
This commit is contained in:
parent
1a86d3459d
commit
b61f5d835c
|
@ -10,6 +10,7 @@ namespace CodexPlugin
|
||||||
{
|
{
|
||||||
string MakeStorageAvailable(ByteSize size, TestToken minPriceForTotalSpace, TestToken maxCollateral, TimeSpan maxDuration);
|
string MakeStorageAvailable(ByteSize size, TestToken minPriceForTotalSpace, TestToken maxCollateral, TimeSpan maxDuration);
|
||||||
StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration);
|
StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration);
|
||||||
|
StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration, TimeSpan expiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MarketplaceAccess : IMarketplaceAccess
|
public class MarketplaceAccess : IMarketplaceAccess
|
||||||
|
@ -25,13 +26,20 @@ namespace CodexPlugin
|
||||||
|
|
||||||
public StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration)
|
public StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration)
|
||||||
{
|
{
|
||||||
|
return RequestStorage(contentId, pricePerSlotPerSecond, requiredCollateral, minRequiredNumberOfNodes, proofProbability, duration, TimeSpan.FromMinutes(5));
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration, TimeSpan expiry)
|
||||||
|
{
|
||||||
|
var expireUtc = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + expiry.TotalSeconds;
|
||||||
|
|
||||||
var request = new CodexSalesRequestStorageRequest
|
var request = new CodexSalesRequestStorageRequest
|
||||||
{
|
{
|
||||||
duration = ToDecInt(duration.TotalSeconds),
|
duration = ToDecInt(duration.TotalSeconds),
|
||||||
proofProbability = ToDecInt(proofProbability),
|
proofProbability = ToDecInt(proofProbability),
|
||||||
reward = ToDecInt(pricePerSlotPerSecond),
|
reward = ToDecInt(pricePerSlotPerSecond),
|
||||||
collateral = ToDecInt(requiredCollateral),
|
collateral = ToDecInt(requiredCollateral),
|
||||||
expiry = null,
|
expiry = ToDecInt(expireUtc),
|
||||||
nodes = minRequiredNumberOfNodes,
|
nodes = minRequiredNumberOfNodes,
|
||||||
tolerance = null,
|
tolerance = null,
|
||||||
};
|
};
|
||||||
|
@ -41,11 +49,14 @@ namespace CodexPlugin
|
||||||
$"requiredCollateral: {requiredCollateral}, " +
|
$"requiredCollateral: {requiredCollateral}, " +
|
||||||
$"minRequiredNumberOfNodes: {minRequiredNumberOfNodes}, " +
|
$"minRequiredNumberOfNodes: {minRequiredNumberOfNodes}, " +
|
||||||
$"proofProbability: {proofProbability}, " +
|
$"proofProbability: {proofProbability}, " +
|
||||||
|
$"expiry: {Time.FormatDuration(expiry)}, " +
|
||||||
$"duration: {Time.FormatDuration(duration)})");
|
$"duration: {Time.FormatDuration(duration)})");
|
||||||
|
|
||||||
var response = codexAccess.RequestStorage(request, contentId.Id);
|
var response = codexAccess.RequestStorage(request, contentId.Id);
|
||||||
|
|
||||||
if (response == "Purchasing not available")
|
if (response == "Purchasing not available" ||
|
||||||
|
response == "Expiry required" ||
|
||||||
|
response == "Expiry needs to be in future")
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(response);
|
throw new InvalidOperationException(response);
|
||||||
}
|
}
|
||||||
|
@ -104,6 +115,12 @@ namespace CodexPlugin
|
||||||
return null!;
|
return null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration, TimeSpan expiry)
|
||||||
|
{
|
||||||
|
Unavailable();
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public string MakeStorageAvailable(ByteSize size, TestToken minPricePerBytePerSecond, TestToken maxCollateral, TimeSpan duration)
|
public string MakeStorageAvailable(ByteSize size, TestToken minPricePerBytePerSecond, TestToken maxCollateral, TimeSpan duration)
|
||||||
{
|
{
|
||||||
Unavailable();
|
Unavailable();
|
||||||
|
|
Loading…
Reference in New Issue