This commit is contained in:
2025-08-21 12:05:20 +02:00
parent 9b2b7283c0
commit 9642922445
32 changed files with 281 additions and 281 deletions

View File

@@ -2,7 +2,6 @@ module datamodel
import time
// NodeTotalSim represents the aggregated data for a node simulation, including hardware specs, pricing, and location.
pub struct NodeTotalSim {
pub mut:
@@ -23,14 +22,14 @@ pub fn (n NodeSim) total() !NodeTotalSim {
}
mut total := NodeTotalSim{
id: n.id
cost: n.cost
deliverytime: time.now() // Placeholder; replace with actual logic if needed
inca_reward: 0 // Placeholder; compute from policy if available
reputation: 50 // Default; compute from uptime/history
uptime: n.uptime
id: n.id
cost: n.cost
deliverytime: time.now() // Placeholder; replace with actual logic if needed
inca_reward: 0 // Placeholder; compute from policy if available
reputation: 50 // Default; compute from uptime/history
uptime: n.uptime
price_simulation: 0.0
capacity: NodeCapacity{}
capacity: NodeCapacity{}
}
// Aggregate from compute slices

View File

@@ -3,46 +3,46 @@ module datamodel
@[heap]
pub struct Node {
pub mut:
id int
nodegroupid int
uptime int // 0..100
computeslices []ComputeSlice
storageslices []StorageSlice
devices DeviceInfo
country string // 2 letter code as specified in lib/data/countries/data/countryInfo.txt, use that library for validation
capacity NodeCapacity // Hardware capacity details
provisiontime u32 //lets keep it simple and compatible
id int
nodegroupid int
uptime int // 0..100
computeslices []ComputeSlice
storageslices []StorageSlice
devices DeviceInfo
country string // 2 letter code as specified in lib/data/countries/data/countryInfo.txt, use that library for validation
capacity NodeCapacity // Hardware capacity details
provisiontime u32 // lets keep it simple and compatible
}
pub struct DeviceInfo {
pub mut:
vendor string
storage []StorageDevice
memory []MemoryDevice
vendor string
storage []StorageDevice
memory []MemoryDevice
cpu []CPUDevice
gpu []GPUDevice
network []NetworkDevice
}
pub struct StorageDevice {
pub mut:
id string //can be used in node
size_gb f64 // Size of the storage device in gigabytes
id string // can be used in node
size_gb f64 // Size of the storage device in gigabytes
description string // Description of the storage device
}
pub struct MemoryDevice {
pub mut:
id string //can be used in node
size_gb f64 // Size of the memory device in gigabytes
id string // can be used in node
size_gb f64 // Size of the memory device in gigabytes
description string // Description of the memory device
}
pub struct CPUDevice {
pub mut:
id string //can be used in node
cores int // Number of CPU cores
passmark int
id string // can be used in node
cores int // Number of CPU cores
passmark int
description string // Description of the CPU
cpu_brand string // Brand of the CPU
cpu_version string // Version of the CPU
@@ -50,19 +50,18 @@ pub mut:
pub struct GPUDevice {
pub mut:
id string //can be used in node
cores int // Number of GPU cores
memory_gb f64 // Size of the GPU memory in gigabytes
id string // can be used in node
cores int // Number of GPU cores
memory_gb f64 // Size of the GPU memory in gigabytes
description string // Description of the GPU
gpu_brand string
gpu_version string
gpu_brand string
gpu_version string
}
pub struct NetworkDevice {
pub mut:
id string //can be used in node
speed_mbps int // Network speed in Mbps
id string // can be used in node
speed_mbps int // Network speed in Mbps
description string // Description of the network device
}
@@ -84,5 +83,5 @@ pub mut:
}
fn (mut n Node) check() ! {
//todo
// todo
}

View File

@@ -1,31 +1,30 @@
module datamodel
// is a root object, is the only obj farmer needs to configure in the UI, this defines how slices will be created
@[heap]
//is a root object, is the only obj farmer needs to configure in the UI, this defines how slices will be created
pub struct NodeGroup {
pub mut:
id u32
farmerid u32 //link back to farmer who owns the nodegroup, is a user?
secret string //only visible by farmer, in future encrypted, used to boot a node
description string
slapolicy SLAPolicy
pricingpolicy PricingPolicy
compute_slice_normalized_pricing_cc f64 //pricing in CC - cloud credit, per 2GB node slice
storage_slice_normalized_pricing_cc f64 //pricing in CC - cloud credit, per 1GB storage slice
reputation int = 50 //between 0 and 100, earned over time
uptime int //between 0 and 100, set by system, farmer has no ability to set this
id u32
farmerid u32 // link back to farmer who owns the nodegroup, is a user?
secret string // only visible by farmer, in future encrypted, used to boot a node
description string
slapolicy SLAPolicy
pricingpolicy PricingPolicy
compute_slice_normalized_pricing_cc f64 // pricing in CC - cloud credit, per 2GB node slice
storage_slice_normalized_pricing_cc f64 // pricing in CC - cloud credit, per 1GB storage slice
reputation int = 50 // between 0 and 100, earned over time
uptime int // between 0 and 100, set by system, farmer has no ability to set this
}
pub struct SLAPolicy {
pub mut:
sla_uptime int //should +90
sla_bandwidth_mbit int //minimal mbits we can expect avg over 1h per node, 0 means we don't guarantee
sla_penalty int //0-100, percent of money given back in relation to month if sla breached, e.g. 200 means we return 2 months worth of rev if sla missed
sla_uptime int // should +90
sla_bandwidth_mbit int // minimal mbits we can expect avg over 1h per node, 0 means we don't guarantee
sla_penalty int // 0-100, percent of money given back in relation to month if sla breached, e.g. 200 means we return 2 months worth of rev if sla missed
}
pub struct PricingPolicy {
pub mut:
marketplace_year_discounts []int = [30,40,50] //e.g. 30,40,50 means if user has more CC in wallet than 1 year utilization on all his purchaes then this provider gives 30%, 2Y 40%, ...
volume_discounts []int = [10,20,30] //e.g. 10,20,30
marketplace_year_discounts []int = [30, 40, 50] // e.g. 30,40,50 means if user has more CC in wallet than 1 year utilization on all his purchaes then this provider gives 30%, 2Y 40%, ...
volume_discounts []int = [10, 20, 30] // e.g. 10,20,30
}

View File

@@ -3,5 +3,5 @@ module datamodel
pub struct NodeSim {
Node
pub mut:
cost f64 //free
cost f64 // free
}

View File

@@ -1,32 +1,29 @@
module datamodel
//typically 1GB of memory, but can be adjusted based based on size of machine
// typically 1GB of memory, but can be adjusted based based on size of machine
pub struct ComputeSlice {
pub mut:
nodeid u32 //the node in the grid, there is an object describing the node
id int //the id of the slice in the node
mem_gb f64
storage_gb f64
passmark int
vcores int
cpu_oversubscription int
storage_oversubscription int
price_range []f64 = [0.0, 0.0]
gpus u8 //nr of GPU's see node to know what GPU's are
price_cc f64 //price per slice (even if the grouped one)
pricing_policy PricingPolicy
sla_policy SLAPolicy
nodeid u32 // the node in the grid, there is an object describing the node
id int // the id of the slice in the node
mem_gb f64
storage_gb f64
passmark int
vcores int
cpu_oversubscription int
storage_oversubscription int
price_range []f64 = [0.0, 0.0]
gpus u8 // nr of GPU's see node to know what GPU's are
price_cc f64 // price per slice (even if the grouped one)
pricing_policy PricingPolicy
sla_policy SLAPolicy
}
//1GB of storage
// 1GB of storage
pub struct StorageSlice {
pub mut:
nodeid u32 //the node in the grid
id int //the id of the slice in the node, are tracked in the node itself
price_cc f64 //price per slice (even if the grouped one)
pricing_policy PricingPolicy
sla_policy SLAPolicy
nodeid u32 // the node in the grid
id int // the id of the slice in the node, are tracked in the node itself
price_cc f64 // price per slice (even if the grouped one)
pricing_policy PricingPolicy
sla_policy SLAPolicy
}

View File

@@ -2,7 +2,6 @@ module datamodelsimulator
import time
// NodeTotalSim represents the aggregated data for a node simulation, including hardware specs, pricing, and location.
pub struct NodeTotalSim {
pub mut:
@@ -23,14 +22,14 @@ pub fn (n NodeSim) total() !NodeTotalSim {
}
mut total := NodeTotalSim{
id: n.id
cost: n.cost
deliverytime: time.now() // Placeholder; replace with actual logic if needed
inca_reward: 0 // Placeholder; compute from policy if available
reputation: 50 // Default; compute from uptime/history
uptime: n.uptime
id: n.id
cost: n.cost
deliverytime: time.now() // Placeholder; replace with actual logic if needed
inca_reward: 0 // Placeholder; compute from policy if available
reputation: 50 // Default; compute from uptime/history
uptime: n.uptime
price_simulation: 0.0
capacity: NodeCapacity{}
capacity: NodeCapacity{}
}
// Aggregate from compute slices

View File

@@ -8,7 +8,7 @@ pub fn play(mut plbook PlayBook) !map[string]&Node {
mut nodesdict := map[string]&Node{}
for action in actions2 {
echo("TODO: Implement action handling for ${action.name}")
echo('TODO: Implement action handling for ${action.name}')
}
return nodesdict
}