Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3279,7 +3279,16 @@ func (s *server) createNewHiddenService(ctx context.Context) error {
// address it can be reached at to our list of advertised addresses.
newNodeAnn, err := s.genNodeAnnouncement(
nil, func(currentAnn *lnwire.NodeAnnouncement1) {
currentAnn.Addresses = append(currentAnn.Addresses, addr)
// Check if this address was already added.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This comment explains what the code does, but not why. According to the style guide, comments should explain the why or the intention of the code.12

Suggested change
// Check if this address was already added.
// Avoid duplicate addresses from Tor restarts.

Style Guide References

Footnotes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the whole list be deleted during restart, so we only have like 1 address in there at least 1 onion address I mean ?

for _, anAddr := range currentAnn.Addresses {
if anAddr.String() == addr.String() {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can use some debug log here

}
}

currentAnn.Addresses = append(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Addresses should be a set (map) to avoid this duplicated addresses issue, but that's a larger PR.

currentAnn.Addresses, addr,
)
},
)
if err != nil {
Expand Down
Loading