[#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 <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-11-29 16:55:31 +03:00 committed by Alex Vanin
parent 40b51b3586
commit ca894fee23

View file

@ -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)")
}