From ca894fee23f91702094927884ce81e3c7a3a0f79 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 29 Nov 2021 16:55:31 +0300 Subject: [PATCH] [#749] neofs-adm: make alphabet size check more robust We can now store wallet for signing manifest groups in the same dir. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-adm/internal/modules/morph/initialize.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index 5c67c8294..a89f319eb 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "path" + "strings" "time" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" @@ -174,7 +175,17 @@ func openAlphabetWallets(walletDir string) ([]*wallet.Wallet, error) { return nil, fmt.Errorf("can't read alphabet wallets dir: %w", err) } - size := len(walletFiles) + var size int +loop: + for i := range walletFiles { + for j := 0; j < len(walletFiles); j++ { + letter := innerring.GlagoliticLetter(j).String() + if strings.HasPrefix(walletFiles[i].Name(), letter) { + size++ + continue loop + } + } + } if size == 0 { return nil, errors.New("alphabet wallets dir is empty (run `generate-alphabet` command first)") }