wip
This commit is contained in:
39
src/objects/grid4/common.rs
Normal file
39
src/objects/grid4/common.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use rhai::{CustomType, TypeBuilder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// SLA policy matching the V spec `SLAPolicy`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
||||
pub struct SLAPolicy {
|
||||
/// should +90
|
||||
pub sla_uptime: i32,
|
||||
/// minimal mbits we can expect avg over 1h per node, 0 means we don't guarantee
|
||||
pub sla_bandwidth_mbit: i32,
|
||||
/// 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 sla_penalty: i32,
|
||||
}
|
||||
|
||||
impl SLAPolicy {
|
||||
pub fn new() -> Self { Self::default() }
|
||||
pub fn sla_uptime(mut self, v: i32) -> Self { self.sla_uptime = v; self }
|
||||
pub fn sla_bandwidth_mbit(mut self, v: i32) -> Self { self.sla_bandwidth_mbit = v; self }
|
||||
pub fn sla_penalty(mut self, v: i32) -> Self { self.sla_penalty = v; self }
|
||||
pub fn build(self) -> Self { self }
|
||||
}
|
||||
|
||||
/// Pricing policy matching the V spec `PricingPolicy`
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
||||
pub struct PricingPolicy {
|
||||
/// e.g. 30,40,50 means if user has more CC in wallet than 1 year utilization
|
||||
/// then this provider gives 30%, 2Y 40%, ...
|
||||
pub marketplace_year_discounts: Vec<i32>,
|
||||
/// e.g. 10,20,30
|
||||
pub volume_discounts: Vec<i32>,
|
||||
}
|
||||
|
||||
impl PricingPolicy {
|
||||
pub fn new() -> Self { Self { marketplace_year_discounts: vec![30, 40, 50], volume_discounts: vec![10, 20, 30] } }
|
||||
pub fn marketplace_year_discounts(mut self, v: Vec<i32>) -> Self { self.marketplace_year_discounts = v; self }
|
||||
pub fn volume_discounts(mut self, v: Vec<i32>) -> Self { self.volume_discounts = v; self }
|
||||
pub fn build(self) -> Self { self }
|
||||
}
|
||||
Reference in New Issue
Block a user