[#645] placement/traverser: Extend Node type with public key

There is a need to process public keys of the placement result.

Implement `Node.PublicKey` method which returns storage node's key announced
in netmap.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-09-06 15:05:04 +03:00 committed by Alex Vanin
parent fe90456dcc
commit 22926e8f28

View file

@ -122,6 +122,8 @@ func flatNodes(ns []netmap.Nodes) []netmap.Nodes {
// Node is a descriptor of storage node with information required for intra-container communication.
type Node struct {
addresses network.AddressGroup
key []byte
}
// Addresses returns group of network addresses.
@ -129,6 +131,11 @@ func (x Node) Addresses() network.AddressGroup {
return x.addresses
}
// Key returns public key in a binary format. Should not be mutated.
func (x Node) Key() []byte {
return x.key
}
// Next returns next unprocessed address of the object placement.
//
// Returns nil if no nodes left or traversal operation succeeded.
@ -157,6 +164,8 @@ func (t *Traverser) Next() []Node {
// TODO: log error
return nil
}
nodes[i].key = t.vectors[0][i].PublicKey()
}
t.vectors[0] = t.vectors[0][count:]