[#11] Trim the old functionality

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-21 14:32:03 +03:00 committed by Alex Vanin
parent 783ec72d56
commit a87fdab324
235 changed files with 39 additions and 36211 deletions

View file

@ -1,37 +1,10 @@
package wrapper
import (
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
)
// NodeInfo groups information about NeoFS storage node.
type NodeInfo struct{}
// AddPeer registers peer in NeoFS network through
// Netmap contract call.
func (w *Wrapper) AddPeer(nodeInfo netmap.Info) error {
// prepare invocation arguments
args := contract.AddPeerArgs{}
info := contract.PeerInfo{}
info.SetPublicKey(nodeInfo.PublicKey())
info.SetAddress([]byte(nodeInfo.Address()))
opts := nodeInfo.Options()
binOpts := make([][]byte, 0, len(opts))
for i := range opts {
binOpts = append(binOpts, []byte(opts[i]))
}
info.SetOptions(binOpts)
args.SetInfo(info)
// invoke smart contract call
//
// Note: errors.Wrap returns nil on nil error arg.
return errors.Wrap(
w.client.AddPeer(args),
"could not invoke smart contract",
)
func (w *Wrapper) AddPeer(nodeInfo NodeInfo) error {
panic("implement me")
}

View file

@ -1,60 +1,12 @@
package wrapper
import (
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
)
// NetMap represents the NeoFS network map.
//
// It is a type alias of
// github.com/nspcc-dev/neofs-node/pkg/core/NetMap.
type NetMap = netmap.NetMap
// Info represents node information.
//
// It is a type alias of
// github.com/nspcc-dev/neofs-node/pkg/core/netmap.Info.
type Info = netmap.Info
// FIXME: correct the definition.
type NetMap struct{}
// GetNetMap receives information list about storage nodes
// through the Netmap contract call, composes network map
// from them and returns it.
func (w *Wrapper) GetNetMap() (*NetMap, error) {
// prepare invocation arguments
args := contract.GetNetMapArgs{}
// invoke smart contract call
values, err := w.client.NetMap(args)
if err != nil {
return nil, errors.Wrap(err, "could not invoke smart contract")
}
// parse response and fill the network map
nm := netmap.New()
peerList := values.Peers()
for i := range peerList {
info := Info{}
info.SetPublicKey(peerList[i].PublicKey())
info.SetAddress(string(peerList[i].Address()))
binOpts := peerList[i].Options()
opts := make([]string, 0, len(binOpts))
for j := range binOpts {
opts = append(opts, string(binOpts[j]))
}
info.SetOptions(opts)
if err := nm.AddNode(info); err != nil {
return nil, errors.Wrapf(err, "could not add node #%d to network map", i)
}
}
return nm, nil
panic("implement me")
}

View file

@ -1,23 +1,11 @@
package wrapper
import (
"github.com/nspcc-dev/neofs-node/pkg/core/netmap/epoch"
contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
"github.com/pkg/errors"
)
// Epoch represents the NeoFS epoch.
// FIXME: correct the definition.
type Epoch struct{}
// NewEpoch updates NeoFS epoch number through
// Netmap contract call.
func (w *Wrapper) NewEpoch(e epoch.Epoch) error {
// prepare invocation arguments
args := contract.NewEpochArgs{}
args.SetEpochNumber(int64(epoch.ToUint64(e)))
// invoke smart contract call
//
// Note: errors.Wrap returns nil on nil error arg.
return errors.Wrap(
w.client.NewEpoch(args),
"could not invoke smart contract",
)
func (w *Wrapper) NewEpoch(e Epoch) error {
panic("implement me")
}