[#132] Put new storage peers in netmap cleaner cache

There is an optimization to send ApprovePeer tx only in
case if `touch` returns false. It returns false if node
is not in the cache or it was flagged to removal.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-10-29 19:01:35 +03:00 committed by Alex Vanin
parent 0c42db2c3c
commit 118f7fb309

View file

@ -28,14 +28,17 @@ func (np *Processor) processAddPeer(node []byte) {
return
}
keyString := hex.EncodeToString(nodeInfo.PublicKey)
np.log.Info("approving network map candidate",
zap.String("key", hex.EncodeToString(nodeInfo.PublicKey)),
)
zap.String("key", keyString))
exists := np.netmapSnapshot.touch(keyString, np.epochState.EpochCounter())
if !exists {
err = invoke.ApprovePeer(np.morphClient, np.netmapContract, node)
if err != nil {
np.log.Error("can't invoke netmap.AddPeer", zap.Error(err))
}
}
}
// Process new epoch tick by invoking new epoch method in network map contract.