Skip to content

Commit 7e694a6

Browse files
committed
wip
1 parent 6d02285 commit 7e694a6

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

ProjectPlugins/CodexClient/CodexClient.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<ProjectReference Include="..\..\Framework\FileUtils\FileUtils.csproj" />
3131
<ProjectReference Include="..\..\Framework\Logging\Logging.csproj" />
3232
<ProjectReference Include="..\..\Framework\WebUtils\WebUtils.csproj" />
33-
<ProjectReference Include="..\CodexContractsPlugin\CodexContractsPlugin.csproj" />
3433
</ItemGroup>
3534

3635
</Project>

ProjectPlugins/CodexClient/StoragePurchaseContract.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using CodexClient.Hooks;
2-
using CodexContractsPlugin.Marketplace;
32
using Logging;
43
using Newtonsoft.Json;
54
using Utils;
@@ -15,7 +14,13 @@ public interface IStoragePurchaseContract
1514
void WaitForStorageContractSubmitted();
1615
void WaitForStorageContractStarted();
1716
void WaitForStorageContractFinished();
18-
void WaitForContractFailed(MarketplaceConfig config);
17+
void WaitForContractFailed(IMarketplaceConfigInput config);
18+
}
19+
20+
public interface IMarketplaceConfigInput
21+
{
22+
int MaxNumberOfSlashes { get; }
23+
TimeSpan PeriodDuration { get; }
1924
}
2025

2126
public class StoragePurchaseContract : IStoragePurchaseContract
@@ -100,7 +105,7 @@ public void WaitForStorageContractFinished()
100105
AssertDuration(SubmittedToFinished, timeout, nameof(SubmittedToFinished));
101106
}
102107

103-
public void WaitForContractFailed(MarketplaceConfig config)
108+
public void WaitForContractFailed(IMarketplaceConfigInput config)
104109
{
105110
if (!contractStartedUtc.HasValue)
106111
{
@@ -122,10 +127,10 @@ public void WaitForContractFailed(MarketplaceConfig config)
122127
WaitForStorageContractState(timeout, StoragePurchaseState.Failed);
123128
}
124129

125-
private TimeSpan TimeNeededToFailEnoughProofsToFreeASlot(MarketplaceConfig config)
130+
private TimeSpan TimeNeededToFailEnoughProofsToFreeASlot(IMarketplaceConfigInput config)
126131
{
127-
var numMissedProofsRequiredForFree = config.Collateral.MaxNumberOfSlashes;
128-
var timePerProof = TimeSpan.FromSeconds(config.Proofs.Period);
132+
var numMissedProofsRequiredForFree = config.MaxNumberOfSlashes;
133+
var timePerProof = config.PeriodDuration;
129134
var result = timePerProof * (numMissedProofsRequiredForFree + 1);
130135

131136
// Times 2!

ProjectPlugins/CodexContractsPlugin/ChainMonitor/PeriodMonitor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
using Utils;
1+
using Logging;
2+
using Utils;
23

34
namespace CodexContractsPlugin.ChainMonitor
45
{
56
public class PeriodMonitor
67
{
8+
private readonly ILog log;
79
private readonly ICodexContracts contracts;
810
private readonly List<PeriodReport> reports = new List<PeriodReport>();
911
private ulong? currentPeriod = null;
1012

11-
public PeriodMonitor(ICodexContracts contracts)
13+
public PeriodMonitor(ILog log, ICodexContracts contracts)
1214
{
15+
this.log = log;
1316
this.contracts = contracts;
1417
}
1518

ProjectPlugins/CodexContractsPlugin/Marketplace/Customizations.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using BlockchainUtils;
33
using Nethereum.Hex.HexConvertors.Extensions;
44
using Newtonsoft.Json;
5+
using CodexClient;
56
using Utils;
67

78
namespace CodexContractsPlugin.Marketplace
@@ -92,5 +93,10 @@ public partial class ReserveSlotFunction : IHasBlock, IHasRequestId, IHasSlotInd
9293
[JsonIgnore]
9394
public BlockTimeEntry Block { get; set; }
9495
}
96+
97+
public partial class MarketplaceConfig : IMarketplaceConfigInput
98+
{
99+
100+
}
95101
}
96102
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

0 commit comments

Comments
 (0)