forked from TrueCloudLab/frostfs-node
[#846] innerring: Use epoch as nonce in cleanup netmap process
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
e3c0288e50
commit
5702349cb2
2 changed files with 19 additions and 5 deletions
|
@ -51,7 +51,7 @@ func (np *Processor) handleAddPeer(ev event.Event) {
|
||||||
// send event to the worker pool
|
// send event to the worker pool
|
||||||
|
|
||||||
err := np.pool.Submit(func() {
|
err := np.pool.Submit(func() {
|
||||||
np.processAddPeer(newPeer.Node())
|
np.processAddPeer(newPeer)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// there system can be moved into controlled degradation stage
|
// there system can be moved into controlled degradation stage
|
||||||
|
@ -91,7 +91,7 @@ func (np *Processor) handleCleanupTick(ev event.Event) {
|
||||||
|
|
||||||
// send event to the worker pool
|
// send event to the worker pool
|
||||||
err := np.pool.Submit(func() {
|
err := np.pool.Submit(func() {
|
||||||
np.processNetmapCleanupTick(cleanup.epoch)
|
np.processNetmapCleanupTick(cleanup)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// there system can be moved into controlled degradation stage
|
// there system can be moved into controlled degradation stage
|
||||||
|
|
|
@ -3,17 +3,18 @@ package netmap
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||||
|
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (np *Processor) processNetmapCleanupTick(epoch uint64) {
|
func (np *Processor) processNetmapCleanupTick(ev netmapCleanupTick) {
|
||||||
if !np.alphabetState.IsAlphabet() {
|
if !np.alphabetState.IsAlphabet() {
|
||||||
np.log.Info("non alphabet mode, ignore new netmap cleanup tick")
|
np.log.Info("non alphabet mode, ignore new netmap cleanup tick")
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := np.netmapSnapshot.forEachRemoveCandidate(epoch, func(s string) error {
|
err := np.netmapSnapshot.forEachRemoveCandidate(ev.epoch, func(s string) error {
|
||||||
key, err := keys.NewPublicKeyFromString(s)
|
key, err := keys.NewPublicKeyFromString(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Warn("can't decode public key of netmap node",
|
np.log.Warn("can't decode public key of netmap node",
|
||||||
|
@ -24,7 +25,20 @@ func (np *Processor) processNetmapCleanupTick(epoch uint64) {
|
||||||
|
|
||||||
np.log.Info("vote to remove node from netmap", zap.String("key", s))
|
np.log.Info("vote to remove node from netmap", zap.String("key", s))
|
||||||
|
|
||||||
err = np.netmapClient.UpdatePeerState(key.Bytes(), netmap.NodeStateOffline)
|
if np.notaryDisabled {
|
||||||
|
err = np.netmapClient.UpdatePeerState(key.Bytes(), netmap.NodeStateOffline)
|
||||||
|
} else {
|
||||||
|
// use epoch as TX nonce to prevent collisions
|
||||||
|
err = np.netmapClient.Morph().NotaryInvoke(
|
||||||
|
np.netmapContract,
|
||||||
|
0,
|
||||||
|
uint32(ev.epoch),
|
||||||
|
netmapEvent.UpdateStateNotaryEvent,
|
||||||
|
int64(netmap.NodeStateOffline.ToV2()),
|
||||||
|
key.Bytes(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Error("can't invoke netmap.UpdateState", zap.Error(err))
|
np.log.Error("can't invoke netmap.UpdateState", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue