-
Notifications
You must be signed in to change notification settings - Fork 33
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
[P2P] feat: add background router #707
Conversation
971c278
to
e79dbe2
Compare
The check succeeded, dismissing the review comment.
edef491
to
a5393e8
Compare
a5393e8
to
4f23c2d
Compare
4f23c2d
to
4407707
Compare
b70d4aa
to
1bdf7ee
Compare
- add RainTreeConfig - add BackgroundConfig - add BaseConfig
5d421c5
to
e57bd7d
Compare
The check succeeded, dismissing the review comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple questions but otherwise almost g2g
// height and peerstore providers. Intended for internal use by other `RouterConfig` | ||
// implementations with common config parameters. | ||
// | ||
// NB: intentionally *not* embedding `baseConfig` to improve readability of usages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand this. So when would you embed a struct inside of another one?
To me this seems like a worthwhile usecase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suggesting never. It doesn't look/feel good from the usage side:
rtCfg := RainTreeConfig{
BaseConfig: BaseConfig{
Host: nil,
Addr: nil,
CurrentHeightProvider: nil,
PeerstoreProvider: nil,
},
MaxNonces: 100,
}
Seeing this 👆 makes me want to write a NewRainTreeConfig()
function which would be a bit ridiculous IMHO given that that the purpose of the config originally was to simplify the NewRainTreeRouter()
function signature.
Additionally, I expect significant simplification may be around the corner for the router interface. I'm anticipating being able to eliminate the need for the background router to hold a reference to either provider (maybe even the pokt addr as well). This would cause further divergence between BackgroundConfig
and RainTreeConfig
, likely making baseConfig
another temporary step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel strongly about not taking embedding seriously as an option because of the impact on readability, given the context. An alternative to defining baseConfig
would be to duplicate the IsValid()
implementation across both RainTreeConfig
and BackgroundConfig
; however, I see the way it's currently written as a simplification of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Reviewer
This PR may be more digestible / reviewable on a commit-by-commit basis. Commits are organized logically and any given line is only modified in a single commit, with few exceptions*.
*(In the interest of preserving the git-time-continuum 👮🚨, this applies in batches of commits between comments or reviews by humans)
Description
Implements a "background router" to work alongside raintree (to be integrated in a future PR) which uses a kademlia DHT for peer discovery and a gossipsub pubsub router for broadcasting and listening.
Issue
Part 1 of #505
Part 1 of #712
Type of change
Please mark the relevant option(s):
List of changes
Transport
interfaceraintree.RainTreeConfig
toutil.RouterConfig
protocol.DefaultTopicStr
toprotocol.BackgroundTopicStr
protocol.PeerDiscoveryNamespace
P2PConfig#MaxMempoolCount
toP2PConfig#MaxNonces
DefaultP2PMaxMempoolCount
toDefaultP2PMaxNonces
Testing
make develop_test
; if any code changes were madeRequired Checklist
godoc
format comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)