2
0
mirror of synced 2025-02-03 12:13:48 +00:00

Updates codexSetup and Marketplace configuration

This commit is contained in:
Ben 2024-03-13 10:14:11 +01:00
parent e42f1ddbd7
commit b7904f7ee0
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
2 changed files with 53 additions and 7 deletions

View File

@ -17,7 +17,7 @@ namespace CodexPlugin
ICodexSetup WithBlockMaintenanceInterval(TimeSpan duration); ICodexSetup WithBlockMaintenanceInterval(TimeSpan duration);
ICodexSetup WithBlockMaintenanceNumber(int numberOfBlocks); ICodexSetup WithBlockMaintenanceNumber(int numberOfBlocks);
ICodexSetup EnableMetrics(); ICodexSetup EnableMetrics();
ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, bool isValidator = false); ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, Action<IMarketplaceSetup> marketplaceSetup);
/// <summary> /// <summary>
/// Provides an invalid proof every N proofs /// Provides an invalid proof every N proofs
/// </summary> /// </summary>
@ -25,6 +25,13 @@ namespace CodexPlugin
ICodexSetup AsPublicTestNet(CodexTestNetConfig testNetConfig); ICodexSetup AsPublicTestNet(CodexTestNetConfig testNetConfig);
} }
public interface IMarketplaceSetup
{
IMarketplaceSetup AsStorageNode();
IMarketplaceSetup AsClientNode();
IMarketplaceSetup AsValidator();
}
public class CodexLogCustomTopics public class CodexLogCustomTopics
{ {
public CodexLogCustomTopics(CodexLogLevel discV5, CodexLogLevel libp2p, CodexLogLevel blockExchange) public CodexLogCustomTopics(CodexLogLevel discV5, CodexLogLevel libp2p, CodexLogLevel blockExchange)
@ -115,9 +122,12 @@ namespace CodexPlugin
return this; return this;
} }
public ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, bool isValidator = false) public ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, Action<IMarketplaceSetup> marketplaceSetup)
{ {
MarketplaceConfig = new MarketplaceInitialConfig(gethNode, codexContracts, initialEth, initialTokens, isValidator); var ms = new MarketplaceSetup();
marketplaceSetup(ms);
MarketplaceConfig = new MarketplaceInitialConfig(ms, gethNode, codexContracts, initialEth, initialTokens);
return this; return this;
} }
@ -146,7 +156,43 @@ namespace CodexPlugin
if (BootstrapSpr != null) yield return $"BootstrapNode={BootstrapSpr}"; if (BootstrapSpr != null) yield return $"BootstrapNode={BootstrapSpr}";
if (StorageQuota != null) yield return $"StorageQuota={StorageQuota}"; if (StorageQuota != null) yield return $"StorageQuota={StorageQuota}";
if (SimulateProofFailures != null) yield return $"SimulateProofFailures={SimulateProofFailures}"; if (SimulateProofFailures != null) yield return $"SimulateProofFailures={SimulateProofFailures}";
if (MarketplaceConfig != null) yield return $"IsValidator={MarketplaceConfig.IsValidator}"; if (MarketplaceConfig != null) yield return $"MarketplaceSetup={MarketplaceConfig.MarketplaceSetup}";
} }
} }
public class MarketplaceSetup : IMarketplaceSetup
{
public bool IsClientNode { get; private set; }
public bool IsStorageNode { get; private set; }
public bool IsValidator { get; private set; }
public IMarketplaceSetup AsClientNode()
{
IsClientNode = true;
return this;
}
public IMarketplaceSetup AsStorageNode()
{
IsStorageNode = true;
return this;
}
public IMarketplaceSetup AsValidator()
{
IsValidator = true;
return this;
}
public override string ToString()
{
var result = "[";
result += IsClientNode ? "(clientNode)" : "()";
result += IsStorageNode ? "(storageNode)" : "()";
result += IsValidator ? "(validator)" : "()";
result += "]";
return result;
}
}
} }

View File

@ -5,19 +5,19 @@ namespace CodexPlugin
{ {
public class MarketplaceInitialConfig public class MarketplaceInitialConfig
{ {
public MarketplaceInitialConfig(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, bool isValidator) public MarketplaceInitialConfig(MarketplaceSetup marketplaceSetup, IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens)
{ {
MarketplaceSetup = marketplaceSetup;
GethNode = gethNode; GethNode = gethNode;
CodexContracts = codexContracts; CodexContracts = codexContracts;
InitialEth = initialEth; InitialEth = initialEth;
InitialTokens = initialTokens; InitialTokens = initialTokens;
IsValidator = isValidator;
} }
public MarketplaceSetup MarketplaceSetup { get; }
public IGethNode GethNode { get; } public IGethNode GethNode { get; }
public ICodexContracts CodexContracts { get; } public ICodexContracts CodexContracts { get; }
public Ether InitialEth { get; } public Ether InitialEth { get; }
public TestToken InitialTokens { get; } public TestToken InitialTokens { get; }
public bool IsValidator { get; }
} }
} }