forked from TrueCloudLab/frostfs-node
[#607] cmd/node: Make reputationClientConstructor to accept AddressGroup
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cede2b4ed7
commit
c444118f47
1 changed files with 11 additions and 30 deletions
|
@ -149,30 +149,13 @@ func (n *innerRingFetcher) InnerRingKeys() ([][]byte, error) {
|
||||||
|
|
||||||
type coreClientConstructor reputationClientConstructor
|
type coreClientConstructor reputationClientConstructor
|
||||||
|
|
||||||
func (x *coreClientConstructor) Get(addrGroup network.AddressGroup) (cc coreclient.Client, err error) {
|
func (x *coreClientConstructor) Get(addrGroup network.AddressGroup) (coreclient.Client, error) {
|
||||||
var c client.Client
|
c, err := (*reputationClientConstructor)(x).Get(addrGroup)
|
||||||
|
if err != nil {
|
||||||
addrGroup.IterateAddresses(func(addr network.Address) bool {
|
return nil, err
|
||||||
c, err = (*reputationClientConstructor)(x).Get(addr)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
cc = c.(coreclient.Client)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return c.(coreclient.Client), nil
|
||||||
}
|
|
||||||
|
|
||||||
type addressGroupClientConstructor reputationClientConstructor
|
|
||||||
|
|
||||||
func (x *addressGroupClientConstructor) Get(addrGroup network.AddressGroup) (c client.Client, err error) {
|
|
||||||
addrGroup.IterateAddresses(func(addr network.Address) bool {
|
|
||||||
c, err = (*reputationClientConstructor)(x).Get(addr)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initObjectService(c *cfg) {
|
func initObjectService(c *cfg) {
|
||||||
|
@ -200,8 +183,6 @@ func initObjectService(c *cfg) {
|
||||||
|
|
||||||
coreConstructor := (*coreClientConstructor)(clientConstructor)
|
coreConstructor := (*coreClientConstructor)(clientConstructor)
|
||||||
|
|
||||||
groupConstructor := (*addressGroupClientConstructor)(coreConstructor)
|
|
||||||
|
|
||||||
irFetcher := &innerRingFetcher{
|
irFetcher := &innerRingFetcher{
|
||||||
sidechain: c.cfgMorph.client,
|
sidechain: c.cfgMorph.client,
|
||||||
}
|
}
|
||||||
|
@ -237,7 +218,7 @@ func initObjectService(c *cfg) {
|
||||||
policer.WithExpansionRate(10),
|
policer.WithExpansionRate(10),
|
||||||
policer.WithTrigger(ch),
|
policer.WithTrigger(ch),
|
||||||
policer.WithRemoteHeader(
|
policer.WithRemoteHeader(
|
||||||
headsvc.NewRemoteHeader(keyStorage, groupConstructor),
|
headsvc.NewRemoteHeader(keyStorage, clientConstructor),
|
||||||
),
|
),
|
||||||
policer.WithLocalAddressSource(c),
|
policer.WithLocalAddressSource(c),
|
||||||
policer.WithHeadTimeout(
|
policer.WithHeadTimeout(
|
||||||
|
@ -525,8 +506,8 @@ func (c *reputationClient) SearchObject(ctx context.Context, prm *client.SearchO
|
||||||
return ids, err
|
return ids, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *reputationClientConstructor) Get(addr network.Address) (client.Client, error) {
|
func (c *reputationClientConstructor) Get(addr network.AddressGroup) (client.Client, error) {
|
||||||
cl, err := c.basicConstructor.Get(network.GroupFromAddress(addr))
|
cl, err := c.basicConstructor.Get(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -534,11 +515,11 @@ func (c *reputationClientConstructor) Get(addr network.Address) (client.Client,
|
||||||
nm, err := netmap.GetLatestNetworkMap(c.nmSrc)
|
nm, err := netmap.GetLatestNetworkMap(c.nmSrc)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for i := range nm.Nodes {
|
for i := range nm.Nodes {
|
||||||
var netAddr network.Address
|
var netAddr network.AddressGroup
|
||||||
|
|
||||||
err := netAddr.FromString(nm.Nodes[i].Address())
|
err := netAddr.FromIterator(nm.Nodes[i])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if netAddr.Equal(addr) {
|
if netAddr.Intersects(addr) {
|
||||||
prm := truststorage.UpdatePrm{}
|
prm := truststorage.UpdatePrm{}
|
||||||
prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey()))
|
prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey()))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue