threefold.models_tfgrid #
these are the models for what we use on threefold
enum BidStatus #
enum BidStatus {
pending
confirmed
assigned
cancelled
done
}
enum BillingPeriod #
enum BillingPeriod {
hourly
monthly
yearly
biannually
triannually
}
enum ContractStatus #
enum ContractStatus {
active
cancelled
error
paused
}
struct Bid #
@[heap]
struct Bid {
db.Base
pub mut:
customer_id u32 // links back to customer for this capacity (user on ledger)
requirements map[string]string // e.g. compute_nodes:10, certified:true
pricing map[string]string // e.g. compute_nodes:10.2 (price per unit), certified_CU: 100.3 (price per CU)
status BidStatus
obligation bool // if obligation then will be charged and money needs to be in escrow
start_date u32 // epoch
end_date u32
signature_user string // signature as done by a user/consumer to validate their identity and intent
billing_period BillingPeriod
}
Bid - ROOT OBJECT
fn (Bid) type_name #
fn (self Bid) type_name() string
fn (Bid) description #
fn (self Bid) description(methodname string) string
fn (Bid) example #
fn (self Bid) example(methodname string) (string, string)
fn (Bid) dump #
fn (self Bid) dump(mut e encoder.Encoder) !
struct BidArg #
@[params]
struct BidArg {
pub mut:
name string
description string
customer_id u32
requirements map[string]string
pricing map[string]string
status BidStatus
obligation bool
start_date u32
end_date u32
signature_user string
billing_period BillingPeriod
}
struct CPUDevice #
struct CPUDevice {
pub mut:
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
}
CPU device information
struct ComputeSlice #
struct ComputeSlice {
pub mut:
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 // Min/max allowed price range for validation
gpus u8 // nr of GPU's see node to know what GPU's are
price_cc f64 // price per slice in cloud credits
pricing_policy PricingPolicy
sla_policy SLAPolicy
}
Compute slice (typically represents a base unit of compute)
struct ComputeSliceProvisioned #
struct ComputeSliceProvisioned {
pub mut:
node_id u32
id u16 // the id of the slice in the node
mem_gb f64
storage_gb f64
passmark int
vcores int
cpu_oversubscription int
tags string
}
Provisioned compute slice
struct Contract #
@[heap]
struct Contract {
db.Base
pub mut:
customer_id u32 // links back to customer for this capacity
compute_slices []ComputeSliceProvisioned
storage_slices []StorageSliceProvisioned
compute_slice_price f64 // price per 1 GB agreed upon
storage_slice_price f64 // price per 1 GB agreed upon
network_slice_price f64 // price per 1 GB agreed upon (transfer)
status ContractStatus
start_date u32 // epoch
end_date u32
signature_user string // signature as done by user/consumer
signature_hoster string // signature as done by the hoster
billing_period BillingPeriod
}
Contract - ROOT OBJECT
fn (Contract) type_name #
fn (self Contract) type_name() string
fn (Contract) description #
fn (self Contract) description(methodname string) string
fn (Contract) example #
fn (self Contract) example(methodname string) (string, string)
fn (Contract) dump #
fn (self Contract) dump(mut e encoder.Encoder) !
struct ContractArg #
@[params]
struct ContractArg {
pub mut:
name string
description string
customer_id u32
compute_slices []ComputeSliceProvisioned
storage_slices []StorageSliceProvisioned
compute_slice_price f64
storage_slice_price f64
network_slice_price f64
status ContractStatus
start_date u32
end_date u32
signature_user string
signature_hoster string
billing_period BillingPeriod
}
struct DBBid #
struct DBBid {
pub mut:
db &db.DB @[skip; str: skip]
}
fn (DBBid) new #
fn (mut self DBBid) new(args BidArg) !Bid
fn (DBBid) set #
fn (mut self DBBid) set(o Bid) !Bid
fn (DBBid) delete #
fn (mut self DBBid) delete(id u32) !
fn (DBBid) exist #
fn (mut self DBBid) exist(id u32) !bool
fn (DBBid) get #
fn (mut self DBBid) get(id u32) !Bid
fn (DBBid) list #
fn (mut self DBBid) list() ![]Bid
struct DBContract #
struct DBContract {
pub mut:
db &db.DB @[skip; str: skip]
}
fn (DBContract) new #
fn (mut self DBContract) new(args ContractArg) !Contract
fn (DBContract) set #
fn (mut self DBContract) set(o Contract) !Contract
fn (DBContract) delete #
fn (mut self DBContract) delete(id u32) !
fn (DBContract) exist #
fn (mut self DBContract) exist(id u32) !bool
fn (DBContract) get #
fn (mut self DBContract) get(id u32) !Contract
fn (DBContract) list #
fn (mut self DBContract) list() ![]Contract
struct DBNode #
struct DBNode {
pub mut:
db &db.DB @[skip; str: skip]
}
fn (DBNode) new #
fn (mut self DBNode) new(args NodeArg) !Node
fn (DBNode) set #
fn (mut self DBNode) set(o Node) !Node
fn (DBNode) delete #
fn (mut self DBNode) delete(id u32) !
fn (DBNode) exist #
fn (mut self DBNode) exist(id u32) !bool
fn (DBNode) get #
fn (mut self DBNode) get(id u32) !Node
fn (DBNode) list #
fn (mut self DBNode) list() ![]Node
struct DBNodeGroup #
struct DBNodeGroup {
pub mut:
db &db.DB @[skip; str: skip]
}
fn (DBNodeGroup) new #
fn (mut self DBNodeGroup) new(args NodeGroupArg) !NodeGroup
fn (DBNodeGroup) set #
fn (mut self DBNodeGroup) set(o NodeGroup) !NodeGroup
fn (DBNodeGroup) delete #
fn (mut self DBNodeGroup) delete(id u32) !
fn (DBNodeGroup) exist #
fn (mut self DBNodeGroup) exist(id u32) !bool
fn (DBNodeGroup) get #
fn (mut self DBNodeGroup) get(id u32) !NodeGroup
fn (DBNodeGroup) list #
fn (mut self DBNodeGroup) list() ![]NodeGroup
struct DBNodeGroupReputation #
struct DBNodeGroupReputation {
pub mut:
db &db.DB @[skip; str: skip]
}
fn (DBNodeGroupReputation) new #
fn (mut self DBNodeGroupReputation) new(args NodeGroupReputationArg) !NodeGroupReputation
fn (DBNodeGroupReputation) set #
fn (mut self DBNodeGroupReputation) set(o NodeGroupReputation) !NodeGroupReputation
fn (DBNodeGroupReputation) delete #
fn (mut self DBNodeGroupReputation) delete(id u32) !
fn (DBNodeGroupReputation) exist #
fn (mut self DBNodeGroupReputation) exist(id u32) !bool
fn (DBNodeGroupReputation) get #
fn (mut self DBNodeGroupReputation) get(id u32) !NodeGroupReputation
fn (DBNodeGroupReputation) list #
fn (mut self DBNodeGroupReputation) list() ![]NodeGroupReputation
struct DeviceInfo #
struct DeviceInfo {
pub mut:
vendor string
storage []StorageDevice
memory []MemoryDevice
cpu []CPUDevice
gpu []GPUDevice
network []NetworkDevice
}
Aggregated device info for a node
struct GPUDevice #
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
description string // Description of the GPU
gpu_brand string
gpu_version string
}
GPU device information
struct MemoryDevice #
struct MemoryDevice {
pub mut:
id string // can be used in node
size_gb f64 // Size of the memory device in gigabytes
description string // Description of the memory device
}
Memory device information
struct NetworkDevice #
struct NetworkDevice {
pub mut:
id string // can be used in node
speed_mbps int // Network speed in Mbps
description string // Description of the network device
}
Network device information
struct Node #
@[heap]
struct Node {
db.Base
pub mut:
nodegroupid int // Link to node group
uptime int // Uptime percentage 0..100
computeslices []ComputeSlice
storageslices []StorageSlice
devices DeviceInfo
country string // 2 letter code
capacity NodeCapacity // Hardware capacity details
birthtime u32 // first time node was active
pubkey string
signature_node string // signature done on node to validate pubkey with privkey
signature_farmer string // signature as done by farmers to validate their identity
}
Grid4 Node model - ROOT OBJECT
fn (Node) type_name #
fn (self Node) type_name() string
fn (Node) description #
fn (self Node) description(methodname string) string
fn (Node) example #
fn (self Node) example(methodname string) (string, string)
fn (Node) dump #
fn (self Node) dump(mut e encoder.Encoder) !
struct NodeArg #
@[params]
struct NodeArg {
pub mut:
name string
description string
nodegroupid int
uptime int
computeslices []ComputeSlice
storageslices []StorageSlice
devices DeviceInfo
country string
capacity NodeCapacity
birthtime u32
pubkey string
signature_node string
signature_farmer string
}
struct NodeCapacity #
struct NodeCapacity {
pub mut:
storage_gb f64 // Total storage in gigabytes
mem_gb f64 // Total memory in gigabytes
mem_gb_gpu f64 // Total GPU memory in gigabytes
passmark int // Passmark score for the node
vcores int // Total virtual cores
}
NodeCapacity represents the hardware capacity details of a node
struct NodeGroup #
@[heap]
struct NodeGroup {
db.Base
pub mut:
farmerid u32 // link back to farmer who owns the nodegroup
secret string // only visible by farmer, in future encrypted, used to boot a node
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
signature_farmer string // signature as done by farmers to validate that they created this group
}
NodeGroup - ROOT OBJECT
fn (NodeGroup) type_name #
fn (self NodeGroup) type_name() string
fn (NodeGroup) description #
fn (self NodeGroup) description(methodname string) string
fn (NodeGroup) example #
fn (self NodeGroup) example(methodname string) (string, string)
fn (NodeGroup) dump #
fn (self NodeGroup) dump(mut e encoder.Encoder) !
struct NodeGroupArg #
@[params]
struct NodeGroupArg {
pub mut:
name string
description string
farmerid u32
secret string
slapolicy SLAPolicy
pricingpolicy PricingPolicy
compute_slice_normalized_pricing_cc f64
storage_slice_normalized_pricing_cc f64
signature_farmer string
}
struct NodeGroupReputation #
@[heap]
struct NodeGroupReputation {
db.Base
pub mut:
nodegroup_id u32
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
nodes []NodeReputation
}
NodeGroupReputation - ROOT OBJECT
fn (NodeGroupReputation) type_name #
fn (self NodeGroupReputation) type_name() string
fn (NodeGroupReputation) description #
fn (self NodeGroupReputation) description(methodname string) string
fn (NodeGroupReputation) example #
fn (self NodeGroupReputation) example(methodname string) (string, string)
fn (NodeGroupReputation) dump #
fn (self NodeGroupReputation) dump(mut e encoder.Encoder) !
struct NodeGroupReputationArg #
@[params]
struct NodeGroupReputationArg {
pub mut:
name string
description string
nodegroup_id u32
reputation int = 50
uptime int
nodes []NodeReputation
}
struct NodeReputation #
struct NodeReputation {
pub mut:
node_id u32
reputation int = 50 // between 0 and 100, earned over time
uptime int // between 0 and 100, set by system
}
Individual node reputation information
struct PricingPolicy #
struct PricingPolicy {
pub mut:
name string // Human friendly policy name (e.g. "fixed", "market")
details string // Optional free-form details as JSON-encoded string
marketplace_year_discounts []int // e.g. [30, 40, 50] means if user has more CC than 1Y utilization, 30% discount, etc.
}
Pricing policy for slices
struct SLAPolicy #
struct SLAPolicy {
pub mut:
uptime f32 // Uptime in percentage (0..100)
max_response_time_ms u32 // Max response time in ms
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
}
SLA policy for slices
struct StorageDevice #
struct StorageDevice {
pub mut:
id string // can be used in node
size_gb f64 // Size of the storage device in gigabytes
description string // Description of the storage device
}
Storage device information
struct StorageSlice #
struct StorageSlice {
pub mut:
id int // the id of the slice in the node
price_cc f64 // price per slice in cloud credits
pricing_policy PricingPolicy
sla_policy SLAPolicy
}
Storage slice (typically 1GB of storage)
struct StorageSliceProvisioned #
struct StorageSliceProvisioned {
pub mut:
node_id u32
id u16 // the id of the slice in the node
storage_size_gb int
tags string
}
Provisioned storage slice
- README
- enum BidStatus
- enum BillingPeriod
- enum ContractStatus
- struct Bid
- struct BidArg
- struct CPUDevice
- struct ComputeSlice
- struct ComputeSliceProvisioned
- struct Contract
- struct ContractArg
- struct DBBid
- struct DBContract
- struct DBNode
- struct DBNodeGroup
- struct DBNodeGroupReputation
- struct DeviceInfo
- struct GPUDevice
- struct MemoryDevice
- struct NetworkDevice
- struct Node
- struct NodeArg
- struct NodeCapacity
- struct NodeGroup
- struct NodeGroupArg
- struct NodeGroupReputation
- struct NodeGroupReputationArg
- struct NodeReputation
- struct PricingPolicy
- struct SLAPolicy
- struct StorageDevice
- struct StorageSlice
- struct StorageSliceProvisioned