2021-04-22 14:56:25 +00:00
|
|
|
package routes
|
2021-04-03 06:11:12 +00:00
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
|
|
|
|
2021-04-03 06:11:12 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
|
2021-04-23 14:54:55 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
|
2021-03-01 19:01:45 +00:00
|
|
|
"go.uber.org/zap"
|
2021-04-03 06:11:12 +00:00
|
|
|
)
|
|
|
|
|
2021-04-22 14:56:25 +00:00
|
|
|
// NextStage builds Manager list for trusted node and returns it directly.
|
2021-04-03 06:11:12 +00:00
|
|
|
//
|
|
|
|
// If passed route has more than one point, then endpoint of the route is reached.
|
2021-04-23 14:54:55 +00:00
|
|
|
func (b *Builder) NextStage(epoch uint64, t reputation.Trust, passed []common.ServerInfo) ([]common.ServerInfo, error) {
|
2021-03-01 19:01:45 +00:00
|
|
|
passedLen := len(passed)
|
|
|
|
|
|
|
|
b.log.Debug("building next stage for trust route",
|
|
|
|
zap.Uint64("epoch", epoch),
|
|
|
|
zap.Int("passed_length", passedLen),
|
|
|
|
)
|
|
|
|
|
|
|
|
if passedLen > 1 {
|
2021-04-03 06:11:12 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:56:25 +00:00
|
|
|
route, err := b.managerBuilder.BuildManagers(epoch, t.Peer())
|
2021-04-03 06:11:12 +00:00
|
|
|
if err != nil {
|
2021-05-18 08:12:51 +00:00
|
|
|
return nil, fmt.Errorf("could not build managers for epoch: %d: %w", epoch, err)
|
2021-04-03 06:11:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return route, nil
|
|
|
|
}
|