forked from TrueCloudLab/frostfs-node
19f9c7eacb
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
39 lines
840 B
Go
39 lines
840 B
Go
package netmap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg"
|
|
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
|
)
|
|
|
|
type executorSvc struct {
|
|
version *pkg.Version
|
|
localNodeInfo *netmap.NodeInfo
|
|
}
|
|
|
|
func NewExecutionService(ni *netmap.NodeInfo, v *pkg.Version) netmap.Service {
|
|
if ni == nil || v == nil {
|
|
// this should never happen, otherwise it programmers bug
|
|
panic("can't create netmap execution service")
|
|
}
|
|
|
|
return &executorSvc{
|
|
version: v,
|
|
localNodeInfo: ni,
|
|
}
|
|
}
|
|
|
|
func (s *executorSvc) LocalNodeInfo(
|
|
_ context.Context,
|
|
_ *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
|
|
|
|
body := new(netmap.LocalNodeInfoResponseBody)
|
|
body.SetVersion(s.version.ToV2())
|
|
body.SetNodeInfo(s.localNodeInfo)
|
|
|
|
resp := new(netmap.LocalNodeInfoResponse)
|
|
resp.SetBody(body)
|
|
|
|
return resp, nil
|
|
}
|