connections: refuse to build zero-length pool

Prevent starting a gateway with no nodes configured.
This commit is contained in:
Roman Khimov 2021-04-29 17:02:15 +03:00 committed by Roman Khimov
parent 61d61a76cc
commit ba293a3ff9

View file

@ -35,6 +35,9 @@ func (pb *PoolBuilder) AddNode(address string, weight float64) *PoolBuilder {
}
func (pb *PoolBuilder) Build(ctx context.Context, options *PoolBuilderOptions) (Pool, error) {
if len(pb.addresses) == 0 {
return nil, errors.New("no NeoFS peers configured")
}
totalWeight := 0.0
for _, w := range pb.weights {
totalWeight += w