From ba293a3ff9f62ed4ed504422f1c7d03231d5f8b8 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 29 Apr 2021 17:02:15 +0300 Subject: [PATCH] connections: refuse to build zero-length pool Prevent starting a gateway with no nodes configured. --- connections/pool.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connections/pool.go b/connections/pool.go index f8b8f57..8e1db20 100644 --- a/connections/pool.go +++ b/connections/pool.go @@ -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