2025-01-16 15:13:16 +01:00
|
|
|
|
using CodexClient;
|
|
|
|
|
|
using FileUtils;
|
|
|
|
|
|
using Utils;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AutoClient
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CodexWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly App app;
|
|
|
|
|
|
|
|
|
|
|
|
public CodexWrapper(App app, ICodexNode node)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.app = app;
|
|
|
|
|
|
Node = node;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ICodexNode Node { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public ContentId UploadFile(string filepath)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Node.UploadFile(TrackedFile.FromPath(app.Log, filepath));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IStoragePurchaseContract RequestStorage(ContentId cid)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = Node.Marketplace.RequestStorage(new StoragePurchaseRequest(cid)
|
|
|
|
|
|
{
|
2025-02-25 15:51:14 +01:00
|
|
|
|
CollateralPerByte = app.Config.CollateralPerByte.TstWei(),
|
2025-01-16 15:13:16 +01:00
|
|
|
|
Duration = TimeSpan.FromMinutes(app.Config.ContractDurationMinutes),
|
|
|
|
|
|
Expiry = TimeSpan.FromMinutes(app.Config.ContractExpiryMinutes),
|
|
|
|
|
|
MinRequiredNumberOfNodes = Convert.ToUInt32(app.Config.NumHosts),
|
|
|
|
|
|
NodeFailureTolerance = Convert.ToUInt32(app.Config.HostTolerance),
|
2025-02-25 15:51:14 +01:00
|
|
|
|
PricePerBytePerSecond = app.Config.PricePerBytePerSecond.TstWei(),
|
2025-01-16 15:13:16 +01:00
|
|
|
|
ProofProbability = 15
|
|
|
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public StoragePurchase? GetStoragePurchase(string pid)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Node.GetPurchaseStatus(pid);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|