forked from TrueCloudLab/frostfs-node
[#938] ir/netmap: Call AddPeer method if existing candidate was updated
In previous implementation IR handler of `AddPeer` notification didn't send registration to contract if existing peer changed has changed its information. as a consequence, the network map members could not update the information without going into offline. Change `processAddPeer` handler to check if * candidate in the network map is a brand new * or information about the network map member was changed and call `AddPeer` method if so. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
0ec8f529ab
commit
68565d9617
3 changed files with 66 additions and 34 deletions
|
@ -50,27 +50,25 @@ func (np *Processor) processAddPeer(ev netmapEvent.AddPeer) {
|
|||
})
|
||||
nodeInfo.SetAttributes(a...)
|
||||
|
||||
// marshal updated node info structure
|
||||
nodeInfoBinary, err := nodeInfo.Marshal()
|
||||
if err != nil {
|
||||
np.log.Warn("could not marshal updated network map candidate",
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
keyString := hex.EncodeToString(nodeInfo.PublicKey())
|
||||
|
||||
exists := np.netmapSnapshot.touch(keyString, np.epochState.EpochCounter())
|
||||
if !exists {
|
||||
updated := np.netmapSnapshot.touch(keyString, np.epochState.EpochCounter(), nodeInfoBinary)
|
||||
|
||||
if updated {
|
||||
np.log.Info("approving network map candidate",
|
||||
zap.String("key", keyString))
|
||||
|
||||
if nr := ev.NotaryRequest(); nr != nil {
|
||||
// notary event case
|
||||
|
||||
var nodeInfoBinary []byte
|
||||
|
||||
nodeInfoBinary, err = nodeInfo.Marshal()
|
||||
if err != nil {
|
||||
np.log.Warn("could not marshal updated network map candidate",
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// create new notary request with the original nonce
|
||||
err = np.netmapClient.Morph().NotaryInvoke(
|
||||
np.netmapClient.ContractAddress(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue