From 34f530095d0197880862d193249c4eaa9ead3425 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Fri, 28 Aug 2020 13:44:50 +0200 Subject: [PATCH] convert prices to siacoin --- res/include/md/hosting.md | 28 ++++++++++++------------ webcontroller/templates.go | 45 +++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/res/include/md/hosting.md b/res/include/md/hosting.md index 566bc82..f0f0ae3 100644 --- a/res/include/md/hosting.md +++ b/res/include/md/hosting.md @@ -13,26 +13,26 @@ requirements on storage and bandwidth pricing for Sia hosts. We will only make contracts with hosts that fullfill all these requirements. Keep in mind that these are maximums, you are allowed to go lower. -| Requirement | Max rate | -|--------------------------|------------------| -| Storage price per month | €1.50 / TB | -| Download price | €1.00 / TB | -| Upload price | €0.50 / TB | -| Contract formation price | €0.01 | -| RPC price | €0.000 000 000 1 | -| Sector access price | €0.000 000 000 1 | -| Collateral per month | €3.00 / TB | +{{$price := .PixelAPI.GetSiaPrice}} + +| Requirement | Max rate EUR | Max rate SC | +|--------------------------|--------------|-------------| +| Storage price per month | € 1.50 / TB | {{ div 1.50 $price | formatSC }} / TB | +| Download price | € 1.00 / TB | {{ div 1 $price | formatSC }} / TB | +| Upload price | € 0.50 / TB | {{ div 0.50 $price | formatSC }} / TB | +| Collateral per month | € 5.00 / TB | {{ div 5 $price | formatSC }} / TB | +| Contract formation price | € 0.01 | {{ div 0.01 $price | formatSC }} | + + + Based on exchange rates from Kraken. + [Explanation of units](https://siawiki.tech/wallet/siacoin). + This may seem low, but keep in mind that these prices are before redundancy. We have to upload all our data three times to the Sia network in order to reach high availability. If you multiply everything by three it becomes much more reasonable. -The RPC price and sector access price are paid every time a single chunk of data -is read from the host. These costs ramp up quickly when frequently downloading -files. Sia only includes these settings as a way to mitigate denial of service -attacks. There is normally no need to increase these settings. - We also can't guarantee that your host will be picked when it fulfills these requirements. If there is enough supply we will only pick the most reliable hosts available. diff --git a/webcontroller/templates.go b/webcontroller/templates.go index 5944756..c453aae 100644 --- a/webcontroller/templates.go +++ b/webcontroller/templates.go @@ -137,7 +137,9 @@ func (tm *TemplateManager) ParseTemplates(silent bool) { "pageNr": tm.pageNr, "add": tm.add, "sub": tm.sub, + "div": tm.div, "formatData": tm.formatData, + "formatSC": tm.formatSC, }) // Parse dynamic templates @@ -235,15 +237,46 @@ func (tm *TemplateManager) pageNr(s string) (nr int) { } return nr } -func (tm *TemplateManager) add(a, b interface{}) int { - return detectInt(a) + detectInt(b) -} -func (tm *TemplateManager) sub(a, b interface{}) int { - return detectInt(a) - detectInt(b) -} +func (tm *TemplateManager) add(a, b interface{}) int { return detectInt(a) + detectInt(b) } +func (tm *TemplateManager) sub(a, b interface{}) int { return detectInt(a) - detectInt(b) } +func (tm *TemplateManager) div(a, b float64) float64 { return a / b } + func (tm *TemplateManager) formatData(i interface{}) string { return util.FormatData(int64(detectInt(i))) } +func (tm *TemplateManager) formatSC(amt float64) string { + var fmtSize = func(n float64, u string) string { + var f string + if n >= 100 { + f = "%.1f" + } else if n >= 10 { + f = "%.2f" + } else { + f = "%.3f" + } + return fmt.Sprintf(f+" "+u, n) + } + // if amt >= 1e12 { + // return fmtSize(amt/1e12, "TS") + // } else if amt >= 1e9 { + // return fmtSize(amt/1e9, "GS") + // } else if amt >= 1e6 { + // return fmtSize(amt/1e6, "MS") + // } else if amt >= 1e3 { + // return fmtSize(amt/1e3, "KS") + if amt >= 1 { + return fmtSize(amt, "SC") + } else if amt >= 1e-3 { + return fmtSize(amt/1e-3, "mS") + } else if amt >= 1e-6 { + return fmtSize(amt/1e-6, "μS") + } else if amt >= 1e-9 { + return fmtSize(amt/1e-9, "nS") + } else if amt >= 1e-12 { + return fmtSize(amt/1e-12, "pS") + } + return fmtSize(amt/1e-24, "H") +} func detectInt(i interface{}) int { switch v := i.(type) {