Skip to content

Commit

Permalink
settings: add validation to auto-announce
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Dec 29, 2023
1 parent 1e1cbc5 commit 70a5347
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion host/settings/announce.go
Expand Up @@ -159,6 +159,12 @@ func (cm *ConfigManager) ProcessConsensusChange(cc modules.ConsensusChange) {
// get the current net address
cm.mu.Lock()
defer cm.mu.Unlock()

if err := validateNetAddress(cm.settings.NetAddress); err != nil {
log.Debug("skipping auto announcement for invalid net address", zap.Error(err))
return
}

currentNetAddress := cm.settings.NetAddress
cm.scanHeight = uint64(cc.BlockHeight)
timestamp := time.Unix(int64(cc.AppliedBlocks[len(cc.AppliedBlocks)-1].Timestamp), 0)
Expand All @@ -168,7 +174,7 @@ func (cm *ConfigManager) ProcessConsensusChange(cc modules.ConsensusChange) {

// if the address hasn't changed, don't reannounce
if cm.scanHeight < nextAnnounceHeight && currentNetAddress == lastAnnouncement.Address {
log.Debug("skipping announcement")
log.Debug("skipping announcement for unchanged address")
return
}

Expand Down

0 comments on commit 70a5347

Please sign in to comment.