[#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,13 +28,16 @@ func (np *Processor) processAddPeer(node []byte) {
return return
} }
keyString := hex.EncodeToString(nodeInfo.PublicKey)
np.log.Info("approving network map candidate", np.log.Info("approving network map candidate",
zap.String("key", hex.EncodeToString(nodeInfo.PublicKey)), zap.String("key", keyString))
)
err = invoke.ApprovePeer(np.morphClient, np.netmapContract, node) exists := np.netmapSnapshot.touch(keyString, np.epochState.EpochCounter())
if err != nil { if !exists {
np.log.Error("can't invoke netmap.AddPeer", zap.Error(err)) err = invoke.ApprovePeer(np.morphClient, np.netmapContract, node)
if err != nil {
np.log.Error("can't invoke netmap.AddPeer", zap.Error(err))
}
} }
} }