forked from TrueCloudLab/frostfs-node
[#1426] services/tree: Do not replicate to a local node
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
7703dd5d7f
commit
886baf3136
1 changed files with 9 additions and 2 deletions
|
@ -1,12 +1,14 @@
|
|||
package tree
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||
|
@ -29,6 +31,7 @@ const (
|
|||
)
|
||||
|
||||
func (s *Service) replicateLoop(ctx context.Context) {
|
||||
rawKey := (*keys.PublicKey)(&s.key.PublicKey).Bytes()
|
||||
for {
|
||||
select {
|
||||
case <-s.closeCh:
|
||||
|
@ -36,7 +39,7 @@ func (s *Service) replicateLoop(ctx context.Context) {
|
|||
return
|
||||
case op := <-s.replicateCh:
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultReplicatorTimeout)
|
||||
err := s.replicate(ctx, op)
|
||||
err := s.replicate(ctx, rawKey, op)
|
||||
cancel()
|
||||
|
||||
if err != nil {
|
||||
|
@ -49,7 +52,7 @@ func (s *Service) replicateLoop(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Service) replicate(ctx context.Context, op movePair) error {
|
||||
func (s *Service) replicate(ctx context.Context, rawKey []byte, op movePair) error {
|
||||
req := newApplyRequest(&op)
|
||||
err := signMessage(req, s.key)
|
||||
if err != nil {
|
||||
|
@ -63,6 +66,10 @@ func (s *Service) replicate(ctx context.Context, op movePair) error {
|
|||
|
||||
var node clientcore.NodeInfo
|
||||
for _, n := range nodes {
|
||||
if bytes.Equal(n.PublicKey(), rawKey) {
|
||||
continue
|
||||
}
|
||||
|
||||
var lastErr error
|
||||
|
||||
n.IterateNetworkEndpoints(func(addr string) bool {
|
||||
|
|
Loading…
Reference in a new issue