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"
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/reputation"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-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 trusting 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)
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
b.log.Debug(logs.RoutesBuildingNextStageForLocalTrustRoute,
|
2021-03-01 19:01:45 +00:00
|
|
|
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-17 16:15:38 +00:00
|
|
|
route, err := b.managerBuilder.BuildManagers(epoch, t.TrustingPeer())
|
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
|
|
|
|
}
|