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

peer: use generic lru #1599

Merged
merged 1 commit into from
Jul 8, 2020
Merged

Conversation

tuxcanfly
Copy link
Contributor

This PR updates sentNonces and knownInventory to use the more generic LRU from Decred. This cuts down the need for maintaining two instances of almost same code i.e mruInventoryMap and mruSentNonces.

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

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

OK

@jcvernaleo jcvernaleo requested review from dajohi and davecgh July 7, 2020 17:26
@jcvernaleo
Copy link
Member

@dajohi @davecgh do either of you see any problem important the code from decred in this way? It seems like a good way to go but wanted to give you two a chance to chime in.

peer/peer.go Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved
@davecgh
Copy link
Member

davecgh commented Jul 7, 2020

I don't see anything wrong with using dcrd modules. Modules are stable and can be used by callers as desired.

@jcvernaleo
Copy link
Member

@davecgh did you have any objections of than the go mod tidy (which was done)? If not I'm going to merge this one.

@jcvernaleo
Copy link
Member

Since there seemed to be no objections and this is important, merging it in now.

@jcvernaleo
Copy link
Member

Actually, @tuxcanfly could you squash this to one commit before I merge?

@davecgh
Copy link
Member

davecgh commented Jul 8, 2020

I didn't test it, but it reads well enough.

@jakesylvestre
Copy link
Collaborator

Will give it a quick test

@tuxcanfly
Copy link
Contributor Author

Squashed 👍

@tuxcanfly
Copy link
Contributor Author

Just a sec, borrowing some updates from @dajohi

While here, also rename and generalize limitMap and apply to
other maps which need to be bounded.
@jcvernaleo
Copy link
Member

@tuxcanfly just squash it when you are ready for final review/merge/

@@ -147,6 +147,25 @@ type peerSyncState struct {
requestedBlocks map[chainhash.Hash]struct{}
}

// limitAdd is a helper function for maps that require a maximum limit by
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does anyone object to this func name? It's called addAndLimitMap in @dajohi code but I thought it was too verbose.

Copy link
Member

Choose a reason for hiding this comment

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

no objection from me

@tuxcanfly
Copy link
Contributor Author

Squashed again.

@jcvernaleo jcvernaleo self-requested a review July 8, 2020 20:43
Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

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

OK

@jcvernaleo jcvernaleo merged commit 875b51c into btcsuite:master Jul 8, 2020
@onyb onyb mentioned this pull request Jul 10, 2020
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.

5 participants