package netmap

import (
	"context"
	"fmt"

	"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
)

// GetNetMap calls "snapshot" method and decodes netmap.NetMap from the response.
func (c *Client) GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) {
	prm := client.TestInvokePrm{}
	prm.SetMethod(snapshotMethod)
	prm.SetArgs(diff)

	res, err := c.client.TestInvoke(ctx, prm)
	if err != nil {
		return nil, fmt.Errorf("test invoke (%s): %w", snapshotMethod, err)
	}

	return DecodeNetMap(res)
}