diff --git a/ProjectPlugins/CodexPlugin/CodexSetup.cs b/ProjectPlugins/CodexPlugin/CodexSetup.cs index ccac252..7e42121 100644 --- a/ProjectPlugins/CodexPlugin/CodexSetup.cs +++ b/ProjectPlugins/CodexPlugin/CodexSetup.cs @@ -17,7 +17,7 @@ namespace CodexPlugin ICodexSetup WithBlockMaintenanceInterval(TimeSpan duration); ICodexSetup WithBlockMaintenanceNumber(int numberOfBlocks); 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 marketplaceSetup); /// /// Provides an invalid proof every N proofs /// @@ -25,6 +25,13 @@ namespace CodexPlugin ICodexSetup AsPublicTestNet(CodexTestNetConfig testNetConfig); } + public interface IMarketplaceSetup + { + IMarketplaceSetup AsStorageNode(); + IMarketplaceSetup AsClientNode(); + IMarketplaceSetup AsValidator(); + } + public class CodexLogCustomTopics { public CodexLogCustomTopics(CodexLogLevel discV5, CodexLogLevel libp2p, CodexLogLevel blockExchange) @@ -115,9 +122,12 @@ namespace CodexPlugin 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 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; } @@ -146,7 +156,43 @@ namespace CodexPlugin if (BootstrapSpr != null) yield return $"BootstrapNode={BootstrapSpr}"; if (StorageQuota != null) yield return $"StorageQuota={StorageQuota}"; 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; + } + } + } diff --git a/ProjectPlugins/CodexPlugin/MarketplaceInitialConfig.cs b/ProjectPlugins/CodexPlugin/MarketplaceInitialConfig.cs index 7c92591..6bd4999 100644 --- a/ProjectPlugins/CodexPlugin/MarketplaceInitialConfig.cs +++ b/ProjectPlugins/CodexPlugin/MarketplaceInitialConfig.cs @@ -5,19 +5,19 @@ namespace CodexPlugin { 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; CodexContracts = codexContracts; InitialEth = initialEth; InitialTokens = initialTokens; - IsValidator = isValidator; } + public MarketplaceSetup MarketplaceSetup { get; } public IGethNode GethNode { get; } public ICodexContracts CodexContracts { get; } public Ether InitialEth { get; } public TestToken InitialTokens { get; } - public bool IsValidator { get; } } }