[#746] morph: Add error return of MagicNumber method

Since morph `Client` works in multi-client mode, there is an error case when
we can not get network magic when all endpoints are unavailable.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-08-26 11:17:31 +03:00 committed by Alex Vanin
parent ad7ad12a0c
commit 85bd2a1cdf
2 changed files with 12 additions and 14 deletions

View file

@ -261,14 +261,19 @@ type netInfo struct {
netState netmap.State
magic interface {
MagicNumber() uint64
MagicNumber() (uint64, error)
}
}
func (n *netInfo) Dump() (*netmapV2.NetworkInfo, error) {
magic, err := n.magic.MagicNumber()
if err != nil {
return nil, err
}
ni := new(netmapV2.NetworkInfo)
ni.SetCurrentEpoch(n.netState.CurrentEpoch())
ni.SetMagicNumber(n.magic.MagicNumber())
ni.SetMagicNumber(magic)
return ni, nil
}