-
Notifications
You must be signed in to change notification settings - Fork 54
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
Fix shutdown save peers utreexo #280
Fix shutdown save peers utreexo #280
Conversation
I have seen the errors on linting and build_docker. I am looking into it. |
I think the build docker error is unrelated, cc @Davidson-Souza |
To fix linting, do I need to use the nightly rust? |
Yes, you can run |
A doubt that I had when writting the code was if I needed to save every utreexo peers or just "good" peers. I opted for just the "good" ones. |
The idea is to save only the ones we are connected to, so they are by definition good |
Is there anything I should improve/modify before merging? |
I was looking deeper on pub fn dump_peers(&self, datadir: &str) -> std::io::Result<()> {
let peers: Vec<_> = self
.addresses
.values()
.cloned()
.map(Into::<DiskLocalAddress>::into)
.collect::<Vec<_>>();
let peers = serde_json::to_string(&peers);
if let Ok(peers) = peers {
std::fs::write(datadir.to_owned() + "/peers.json", peers)?;
}
Ok(())
} Maybe the work here can be hooking this to do what |
This is our address database, it saves all known address. The functionality we are discussing here is saving only peers we are currently connected. |
Yes, i can see this... maybe i expressed my idea poorly. we could do a nested functionality with this function, saving the addresses and our best peers... I understand if you disagree with this because of organization. |
I did the method here, but I haven't find a better way to verify other than starting the node and shutting it down. My question now is should I nest both features or not? Or rather, should I first commit and push the modified version before trying to nest these functionalities? |
An unrelated question: Is the peer id=0 always "my running node"? |
They should be independent. One is called periodically, the other should only be called on shutdown.
Not sure if I get your question. RunningNode is a state we can be in (out of: ChainSelector and SyncNode) not something about our peers |
If i go to The
The However, the |
The way you already implemented is what I had in mind. No need to change |
I'll push the commits so you can test and review it. |
…ager to a method that saves only the connected utreexo peers
@Davidson-Souza I realized that as I used .unwrap() to modify the type of peers_id It also made me realize I need to add a functional test to check for this behavior of panicking during shutdown. What do you think? |
ACK 3e70ae9. |
Added code to save good utreexo peers to a anchors.json file