forked from TrueCloudLab/frostfs-node
Add Inner Ring code
This commit is contained in:
parent
dadfd90dcd
commit
b7b5079934
400 changed files with 11420 additions and 8690 deletions
46
pkg/core/netmap/node/options.go
Normal file
46
pkg/core/netmap/node/options.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/object"
|
||||
)
|
||||
|
||||
const optionPrice = "/Price:"
|
||||
|
||||
const optionCapacity = "/Capacity:"
|
||||
|
||||
// Price parses node options and returns the price in 1e-8*GAS/Megabyte per month.
|
||||
//
|
||||
// User sets the price in GAS/Terabyte per month.
|
||||
func (i Info) Price() uint64 {
|
||||
for j := range i.opts {
|
||||
if strings.HasPrefix(i.opts[j], optionPrice) {
|
||||
n, err := strconv.ParseFloat(i.opts[j][len(optionPrice):], 64)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return uint64(n*1e8) / uint64(object.UnitsMB) // UnitsMB == megabytes in 1 terabyte
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// Capacity parses node options and returns the capacity .
|
||||
func (i Info) Capacity() uint64 {
|
||||
for j := range i.opts {
|
||||
if strings.HasPrefix(i.opts[j], optionCapacity) {
|
||||
n, err := strconv.ParseUint(i.opts[j][len(optionCapacity):], 10, 64)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue