[#496] pkg/innerring: provide wrappers to processors

The only thing we need hashes for is to process notifications.
Balance contract if left for now, as it has some initialization.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-05-31 14:50:11 +03:00 committed by Alex Vanin
parent 9b87e6267d
commit 8a2b7f4501
24 changed files with 215 additions and 228 deletions

View file

@ -154,3 +154,8 @@ func (w *Wrapper) readStringConfig(key string) (string, error) {
return str, nil
}
// SetConfig sets config field.
func (w *Wrapper) SetConfig(id, key []byte, value interface{}) error {
return w.client.SetConfig(id, key, value)
}

View file

@ -0,0 +1,8 @@
package wrapper
import "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
// SetInnerRing updates inner ring keys.
func (w *Wrapper) SetInnerRing(keys keys.PublicKeys) error {
return w.client.SetInnerRing(keys)
}

View file

@ -1,11 +1,12 @@
package wrapper
// Epoch represents the NeoFS epoch.
// FIXME: correct the definition.
type Epoch struct{}
import "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
// NewEpoch updates NeoFS epoch number through
// Netmap contract call.
func (w *Wrapper) NewEpoch(e Epoch) error {
panic("implement me")
func (w *Wrapper) NewEpoch(e uint64) error {
var args netmap.NewEpochArgs
args.SetEpochNumber(int64(e))
return w.client.NewEpoch(args)
}

View file

@ -0,0 +1,28 @@
package wrapper
import (
"fmt"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
netmap2 "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
)
// Fetch returns current netmap node infos.
// Consider using pkg/morph/client/netmap for this.
func (w *Wrapper) Snapshot() (*netmap.Netmap, error) {
res, err := w.client.Snapshot(netmap2.GetSnapshotArgs{})
if err != nil {
return nil, err
}
peers := res.Peers()
result := make([]netmap.NodeInfo, len(peers))
for i := range peers {
if err := result[i].Unmarshal(peers[i]); err != nil {
return nil, fmt.Errorf("can't unmarshal node info: %w", err)
}
}
return netmap.NewNetmap(netmap.NodesFromInfo(result))
}