[#1793] node: Serve NetmapService.NetmapSnapshot RPC

There is no more need to serve the same request on Control API.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-09-17 16:37:01 +04:00 committed by fyrchik
parent 59de20fbba
commit 485a5418d2
33 changed files with 653 additions and 1238 deletions

View file

@ -26,6 +26,10 @@ type NodeState interface {
// Must return current node state
// in NeoFS API v2 NodeInfo structure.
LocalNodeInfo() (*netmap.NodeInfo, error)
// ProcessCurrentNetMap passes current local network map of the storage node
// into the given handler.
ProcessCurrentNetMap(func(netmapSDK.NetMap))
}
// NetworkInfo encapsulates source of the
@ -123,3 +127,19 @@ func (s *executorSvc) NetworkInfo(
return resp, nil
}
func (s *executorSvc) Snapshot(_ context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) {
var nmV2 netmap.NetMap
s.state.ProcessCurrentNetMap(func(netMap netmapSDK.NetMap) {
netMap.WriteToV2(&nmV2)
})
body := new(netmap.SnapshotResponseBody)
body.SetNetMap(&nmV2)
resp := new(netmap.SnapshotResponse)
resp.SetBody(body)
return resp, nil
}