Since Go 1.22 a `for` statement with a `range` clause is able
to iterate through integer values from zero to an upper limit.
gopatch script:
@@
var i, e expression
@@
-for i := 0; i <= e - 1; i++ {
+for i := range e {
...
}
@@
var i, e expression
@@
-for i := 0; i <= e; i++ {
+for i := range e + 1 {
...
}
@@
var i, e expression
@@
-for i := 0; i < e; i++ {
+for i := range e {
...
}
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
* Since EC field tags are renumerated, it is required
to regenerate netmap grpc.
* Add a generator with EC replica to check it with
unit-test.
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
I knew one day `sed` would save me an hour of manual work:
```
sed -i -n -e '
s/) Set/) Set/
p
t setter
b end
:setter
n
s/nil/nil/
t hasif
p
b end
:hasif
n
:loop
p
n
s/}/}/
t end
b loop
:end
' $@
goimports -w $@
```
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
The speed of copying (which is done regulary for e.g. subnet changes)
is less, however it isn't on the hot path and the absolute time
difference is insignificant.
```
name old time/op new time/op delta
NodeAttributes-8 96.2ns ± 1% 158.3ns ± 1% +64.61% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
NodeAttributes-8 32.0B ± 0% 32.0B ± 0% ~ (all equal)
name old allocs/op new allocs/op delta
NodeAttributes-8 2.00 ± 0% 2.00 ± 0% ~ (all equal)
```
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
Support:
* new status codes (object, container, session);
* object `Lock` message;
* different signature schemes.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Return any error other than `ErrRemoveSubnet` from `IterateSubnets`
during post-loop processing of zero subnet.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
API changes:
* Rename `Enters` method of the `NodeSubnetInfo` to `Enabled`.
* Declare undefined behavior of `WriteSubnetInfo` with non-unique
attributes.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
For now we don't need to distinguish cases of missing zero subnet's
attribute and the one with `True` value.
Remove local enum `zeroStatus` of `IterateSubnets` since we need to
distinguish between two statuses and use `bool` variable for this.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Node attributes must be key-unique. In current implementation
`IterateSubnets` doesn't monitor the uniqueness of keys.
Declare undefined behavior of `IterateSubnets` for non-unique attribute
keys.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Each NeoFS storage node should be present in at least one subnet.
Make `netmap.IterateSubnets` function to return an error if the node by the
end of the loop does not belong to any subnet.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
NeoFS storage node can participate in a subnet group (at least one).
According to NeoFS API V2 protocol, subnets are entered and exited through
the attributes of the node. We should provide functionality for conveniently
setting and reading attributes based on the needs of the network.
Define `NodeSubnetInfo` type which groups information about the subnet
reflected in `NodeInfo`. Implement `WriteSubnetInfo` function which writes
`SubnetInfo` data to `NodeInfo`. It will be used to prepare a request for
registration on the NeoFS network. Implement `IterateSubnets` function which
allows to iterate over all subnets of the node. Moreover, it allows you to
remove a subnet from the `NodeInfo` right during iterative traversal.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>