Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Fix memory store signed peer record bug #133

Merged
merged 2 commits into from
Mar 30, 2020
Merged

Conversation

aarshkshah1992
Copy link
Contributor

The addrs can very well be nil. However, we should remove the signed peer records entry ONLY if we end up expiring all addresses we Have.

Comment on lines 255 to 257
if len(amap) == 0 {
delete(s.signedPeerRecords, p)
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what the original code was trying to do anyway.

I think for the code to really do what the comment claims to do, it would have to:

  1. Go through all addresses in the peer record.
  2. Check if we still have them.
  3. If we don't, remove the signed record.

This just clears the record if we have no more addresses. But the method that actually adds addresses to a peer shouldn't be the one doing this; it should be done by the GC routine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yusefnapora Do we need to clear this record in addAddrs for some reason ? If not, I can get rid of this code path completely.

Copy link
Contributor

Choose a reason for hiding this comment

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

you guys are right; this isn't needed and was likely leftover from when we only had one type of addr. thanks for catching @aarshkshah1992

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

I think this code was left over from when we didn't have a background GC job and manually garbage collected addresses on add/get.

@Stebalien Stebalien merged commit 1019086 into master Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants