Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peerstore: limit number of non connected peers in addrbook #2971

Merged
merged 8 commits into from
Oct 17, 2024

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Sep 19, 2024

No description provided.

@sukunrt sukunrt marked this pull request as ready for review September 25, 2024 18:13
@sukunrt sukunrt requested a review from MarcoPolo September 30, 2024 16:18
@MarcoPolo MarcoPolo mentioned this pull request Oct 9, 2024
30 tasks
@@ -133,13 +138,17 @@ type AddrBook interface {
// cab.ConsumePeerRecord(signedPeerRecord, aTTL)
// }
type CertifiedAddrBook interface {
// A CertifiedAddrBook is an address book. To remove peers, use the available
// methods on the AddrBook.
AddrBook
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've removed this

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no way to remove a certified peer record from the CertifiedAddrBook. You cannot use the CertifiedAddrBook without an AddrBook, so I made it an AddrBook.

heapIndex int
}

func (e *expiringAddr) ExpiredBy(t time.Time) bool {
return !t.Before(e.Expiry)
}

var expiringAddrPool = sync.Pool{New: func() any { return &expiringAddr{} }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you expand a bit what prompted the change to add a pool? And did you see a perf difference in the benchmark?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't have a benchmark. I'll add one.

p2p/host/peerstore/pstoremem/addr_book.go Outdated Show resolved Hide resolved
p2p/host/peerstore/pstoremem/addr_book.go Outdated Show resolved Hide resolved
p2p/host/peerstore/pstoremem/addr_book.go Outdated Show resolved Hide resolved
@MarcoPolo MarcoPolo force-pushed the sukun/peerstore-limit branch from 5f91eda to 9bed4bc Compare October 17, 2024 02:51
@MarcoPolo MarcoPolo merged commit 26c9014 into master Oct 17, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants