mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
Fix bug: handle adding pubkey to relay picker more than once
This commit is contained in:
parent
880b29384c
commit
a32ca7733a
@ -113,6 +113,17 @@ impl RelayTracker {
|
||||
}
|
||||
|
||||
pub fn add_someone(&self, pubkey: PublicKeyHex) -> Result<(), Error> {
|
||||
// Check if we already have them
|
||||
if self.pubkey_counts.get(&pubkey).is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
for elem in self.relay_assignments.iter() {
|
||||
let assignment = elem.value();
|
||||
if assignment.pubkeys.contains(&pubkey) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
self.pubkey_counts
|
||||
.insert(pubkey, self.num_relays_per_person.load(Ordering::Relaxed));
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user