summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-12-04 19:46:45 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2022-12-04 19:54:19 +0100
commit9637cefdebe3e1425034a5c3e7ba9137d564e6db (patch)
tree4e7c7d1d46b363a70a9471018851acc456fafbf5
parent70a88f64af300fee9b0576c6df167df2a415c4d9 (diff)
Pass existing peer info when registering peer list watcher
-rw-r--r--src/network.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/network.cpp b/src/network.cpp
index fa816bd..4e802f9 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -211,6 +211,13 @@ Peer PeerList::at(size_t i) const
void PeerList::onUpdate(function<void(size_t, const Peer *)> w)
{
+ scoped_lock lock(p->dataMutex);
+ for (size_t i = 0; i < p->peers.size(); i++) {
+ if (auto speer = p->peers[i]->speer.lock()) {
+ Peer peer(speer->lpeer);
+ w(i, &peer);
+ }
+ }
p->watchers.push_back(w);
}