diff --git a/pkg/netmap/filter.go b/pkg/netmap/filter.go index 6838802..37b106a 100644 --- a/pkg/netmap/filter.go +++ b/pkg/netmap/filter.go @@ -115,9 +115,9 @@ func (c *Context) matchKeyValue(f *Filter, b *Node) bool { var attr uint64 switch f.Key() { - case PriceAttr: + case AttrPrice: attr = b.Price - case CapacityAttr: + case AttrCapacity: attr = b.Capacity default: var err error diff --git a/pkg/netmap/node_info.go b/pkg/netmap/node_info.go index a4debbc..90cccfa 100644 --- a/pkg/netmap/node_info.go +++ b/pkg/netmap/node_info.go @@ -44,8 +44,13 @@ const ( // Enumeration of well-known attributes. const ( - CapacityAttr = "Capacity" - PriceAttr = "Price" + // AttrPrice is a key to the node attribute that indicates the + // price in GAS tokens for storing one GB of data during one Epoch. + AttrPrice = "Price" + + // AttrCapacity is a key to the node attribute that indicates the + // total available disk space in Gigabytes. + AttrCapacity = "Capacity" ) var _ hrw.Hasher = (*Node)(nil) @@ -77,9 +82,9 @@ func newNodeV2(index int, ni *NodeInfo) *Node { for _, attr := range ni.Attributes() { switch attr.Key() { - case CapacityAttr: + case AttrCapacity: n.Capacity, _ = strconv.ParseUint(attr.Value(), 10, 64) - case PriceAttr: + case AttrPrice: n.Price, _ = strconv.ParseUint(attr.Value(), 10, 64) } diff --git a/pkg/netmap/selector_test.go b/pkg/netmap/selector_test.go index e434821..e8e1f32 100644 --- a/pkg/netmap/selector_test.go +++ b/pkg/netmap/selector_test.go @@ -303,15 +303,15 @@ func TestPlacementPolicy_ProcessSelectorsHRW(t *testing.T) { // bucket weight order: RU > DE > FR nodes := []NodeInfo{ - nodeInfoFromAttributes("Country", "Germany", PriceAttr, "2", CapacityAttr, "10000"), - nodeInfoFromAttributes("Country", "Germany", PriceAttr, "4", CapacityAttr, "1"), - nodeInfoFromAttributes("Country", "France", PriceAttr, "3", CapacityAttr, "10"), - nodeInfoFromAttributes("Country", "Russia", PriceAttr, "2", CapacityAttr, "10000"), - nodeInfoFromAttributes("Country", "Russia", PriceAttr, "1", CapacityAttr, "10000"), - nodeInfoFromAttributes("Country", "Russia", CapacityAttr, "10000"), - nodeInfoFromAttributes("Country", "France", PriceAttr, "100", CapacityAttr, "1"), - nodeInfoFromAttributes("Country", "France", PriceAttr, "7", CapacityAttr, "10000"), - nodeInfoFromAttributes("Country", "Russia", PriceAttr, "2", CapacityAttr, "1"), + nodeInfoFromAttributes("Country", "Germany", AttrPrice, "2", AttrCapacity, "10000"), + nodeInfoFromAttributes("Country", "Germany", AttrPrice, "4", AttrCapacity, "1"), + nodeInfoFromAttributes("Country", "France", AttrPrice, "3", AttrCapacity, "10"), + nodeInfoFromAttributes("Country", "Russia", AttrPrice, "2", AttrCapacity, "10000"), + nodeInfoFromAttributes("Country", "Russia", AttrPrice, "1", AttrCapacity, "10000"), + nodeInfoFromAttributes("Country", "Russia", AttrCapacity, "10000"), + nodeInfoFromAttributes("Country", "France", AttrPrice, "100", AttrCapacity, "1"), + nodeInfoFromAttributes("Country", "France", AttrPrice, "7", AttrCapacity, "10000"), + nodeInfoFromAttributes("Country", "Russia", AttrPrice, "2", AttrCapacity, "1"), } nm, err := NewNetmap(NodesFromInfo(nodes)) require.NoError(t, err)