From aacfd8ab91fb4638ea99fce7aa8cf6edea3ac231 Mon Sep 17 00:00:00 2001 From: Fedor Partanskiy Date: Sat, 26 Aug 2023 12:41:13 +0300 Subject: [PATCH] Change init metrics black list Signed-off-by: Fedor Partanskiy --- pkg/consensus/consensus.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index 15e4cff4..50119e63 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -216,20 +216,9 @@ func (c *Consensus) reconfig(reconfig types.Reconfig) { c.Logger.Panicf("Configuration is invalid, error: %v", err) } - tmp := c.nodes - var newNodes []uint64 + old := c.nodes c.setNodes(reconfig.CurrentNodes) - -OuterLoop: - for _, i := range c.nodes { - for _, j := range tmp { - if i == j { - continue OuterLoop - } - } - newNodes = append(newNodes, i) - } - c.Metrics.MetricsBlacklist.Initialize(newNodes) + c.initMetricsBlacklistReconfigure(old) c.createComponents() opts := algorithm.PoolOptions{ @@ -262,6 +251,21 @@ OuterLoop: c.Logger.Debugf("Reconfig is done") } +func (c *Consensus) initMetricsBlacklistReconfigure(old []uint64) { + var newNodes []uint64 + +OuterLoop: + for _, i := range c.nodes { + for _, j := range old { + if i == j { + continue OuterLoop + } + } + newNodes = append(newNodes, i) + } + c.Metrics.MetricsBlacklist.Initialize(newNodes) +} + func (c *Consensus) close() { c.stopOnce.Do( func() {