updates marketplace contract, fixes type conversions

This commit is contained in:
ThatBen 2025-02-21 14:17:13 +01:00
parent dc7a034566
commit 0c961b8348
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
6 changed files with 75 additions and 61 deletions

View File

@ -61,7 +61,8 @@ namespace KubernetesWorkflow
var startResult = controller.BringOnline(recipes, location);
var containers = CreateContainers(startResult, recipes, startupConfig);
var rc = new RunningPod(Guid.NewGuid().ToString(), startupConfig, startResult, containers);
var info = GetPodInfo(startResult.Deployment);
var rc = new RunningPod(Guid.NewGuid().ToString(), info, startupConfig, startResult, containers);
cluster.Configuration.Hooks.OnContainersStarted(rc);
if (startResult.ExternalService != null)
@ -83,9 +84,14 @@ namespace KubernetesWorkflow
});
}
public PodInfo GetPodInfo(RunningDeployment deployment)
{
return K8s(c => c.GetPodInfo(deployment));
}
public PodInfo GetPodInfo(RunningContainer container)
{
return K8s(c => c.GetPodInfo(container.RunningPod.StartResult.Deployment));
return GetPodInfo(container.RunningPod.StartResult.Deployment);
}
public PodInfo GetPodInfo(RunningPod pod)

View File

@ -4,9 +4,10 @@ namespace KubernetesWorkflow.Types
{
public class RunningPod
{
public RunningPod(string id, StartupConfig startupConfig, StartResult startResult, RunningContainer[] containers)
public RunningPod(string id, PodInfo podInfo, StartupConfig startupConfig, StartResult startResult, RunningContainer[] containers)
{
Id = id;
PodInfo = podInfo;
StartupConfig = startupConfig;
StartResult = startResult;
Containers = containers;
@ -15,6 +16,7 @@ namespace KubernetesWorkflow.Types
}
public string Id { get; }
public PodInfo PodInfo { get; }
public StartupConfig StartupConfig { get; }
public StartResult StartResult { get; }
public RunningContainer[] Containers { get; }

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@ namespace CodexPlugin
name: container.Name,
imageName: container.Recipe.Image,
startUtc: container.Recipe.RecipeCreatedUtc,
discoveryEndpoint: container.GetInternalAddress(CodexContainerRecipe.DiscoveryPortTag),
discoveryEndpoint: SetClusterInternalIpAddress(pod, container.GetInternalAddress(CodexContainerRecipe.DiscoveryPortTag)),
apiEndpoint: container.GetAddress(CodexContainerRecipe.ApiPortTag),
listenEndpoint: container.GetInternalAddress(CodexContainerRecipe.ListenPortTag),
ethAccount: container.Recipe.Additionals.Get<EthAccount>(),
@ -22,13 +22,14 @@ namespace CodexPlugin
);
}
// todo: is this needed for the discovery address??
//var info = codexAccess.GetPodInfo();
//return new Address(
// logName: $"{GetName()}:DiscoveryPort",
// host: info.Ip,
// port: Container.Recipe.GetPortByTag(CodexContainerRecipe.DiscoveryPortTag)!.Number
//);
private static Address SetClusterInternalIpAddress(RunningPod pod, Address address)
{
return new Address(
logName: address.LogName,
host: pod.PodInfo.Ip,
port: address.Port
);
}
private static Address? GetMetricsEndpoint(RunningContainer container)
{

View File

@ -78,6 +78,11 @@ namespace MarketInsights
average.ProofProbability = GetNewAverage(average.ProofProbability, average.Number, requestEvent.Request.Request.Ask.ProofProbability);
}
private float GetNewAverage(float currentAverage, int newNumberOfValues, ulong newValue)
{
return GetNewAverage(currentAverage, newNumberOfValues, Convert.ToSingle(newValue));
}
private float GetNewAverage(float currentAverage, int newNumberOfValues, BigInteger newValue)
{
return GetNewAverage(currentAverage, newNumberOfValues, (float)newValue);

View File

@ -95,8 +95,8 @@ namespace TestNetRewarder
private bool MeetsSizeRequirement(IChainStateRequest r)
{
var slotSize = r.Request.Ask.SlotSize.ToDecimal();
decimal min = reward.CheckConfig.MinSlotSize.SizeInBytes;
var slotSize = r.Request.Ask.SlotSize;
ulong min = Convert.ToUInt64(reward.CheckConfig.MinSlotSize.SizeInBytes);
return slotSize >= min;
}