-
Notifications
You must be signed in to change notification settings - Fork 184
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
feat(iroh-net): persist known peer info #1488
feat(iroh-net): persist known peer info #1488
Conversation
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.
Looks good!
## Description - Adds a `AddrInfo` that contains the addressing information of peers. This is necessary as it's own type since it's serialized both in gossip and in #1488 - Renames `NodeAddr` to `PeerData` (better name suggestions are well received) this helps consolidate the "peer" terminology already present throughout gossip, sync, downloader, and many other places - Use this type in different parts of the code. Some other types that can be replaced by this are left to #1493 ## Notes & open questions This applies the suggestion of doing `connect` using the full type. It's debatable if this is better than `connect(PublicKey, AddrInfo)` but both are imo an improvement over the current way since the idea if "what does iroh need to connect to a peer" is now fully described in a type ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [ ] Tests if relevant.
msock_sender: mpsc::Sender<ActorMessage>, | ||
) -> anyhow::Result<Self> { | ||
let mut me = PeerMap::default(); | ||
let contents = std::fs::read(path)?; |
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.
We could read in chunks here. However the file would need to get really big for this to be an issue. A PeerAddr
will take less than 100 bytes even with a few socket addresses. So if you store 10.000 peers that'd do a ~1MB allocation here. Could make it async then too. However as this is only run once when binding the socket it won't matter much in practice I'd guess.
I think it's fine to keep as-is now, and we could move to chunked reading easily in a follow-up.
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.
LGTM! Let's get this in 👍
We might want to add a full test with a "recovering" endpoint (shutdown, restart, reconnect) to test the save-on-shutdown and read-on-bin, but that can also be a followup I'd say.
## Description Adds an e2e test for #1488 ## Notes & open questions na ## Change checklist - [x] Self-review. - [ ] Documentation updates if relevant. - [x] Tests if relevant.
## Description Rough list of changes - add an option to the `MagicEndpointBuilder` to set the path in which peers are saved. This is used to read peers on start up and store them on an interval and on shutdown. - add `KnownPeers` to ease serializing and deserializing peer info - move the logic of `add_known_addr` to the `PeerMap` to facilitate instantiating from a known peer list - Add an `IrohPath` for the peers. - Add an option to the `Node`s builder to set the path, passed down to the endpoint. - For serialization it makes sense to have an object modelling the peer addressing info. This is the `AddrInfo`, which now replaces the custom `IrohInfo` ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [x] Tests if relevant.
Description
Rough list of changes
MagicEndpointBuilder
to set the path in which peers are saved. This is used to read peers on start up and store them on an interval and on shutdown.KnownPeers
to ease serializing and deserializing peer infoadd_known_addr
to thePeerMap
to facilitate instantiating from a known peer listIrohPath
for the peers.Node
s builder to set the path, passed down to the endpoint.AddrInfo
, which now replaces the customIrohInfo
Notes & open questions
Change checklist