MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / promote_group_learner

Method promote_group_learner

nodedb-cluster/src/routing.rs:230–241  ·  view source on GitHub ↗

Promote a learner to a voter within a group. Returns `true` if the learner was found and promoted.

(&mut self, group_id: u64, peer: u64)

Source from the content-addressed store, hash-verified

228 /// Promote a learner to a voter within a group. Returns `true` if the
229 /// learner was found and promoted.
230 pub fn promote_group_learner(&mut self, group_id: u64, peer: u64) -> bool {
231 if let Some(info) = self.group_members.get_mut(&group_id)
232 && let Some(pos) = info.learners.iter().position(|&id| id == peer)
233 {
234 info.learners.remove(pos);
235 if !info.members.contains(&peer) {
236 info.members.push(peer);
237 }
238 return true;
239 }
240 false
241 }
242
243 /// Access the vshard-to-group mapping (for persistence / wire transfer).
244 pub fn vshard_to_group(&self) -> &[u64] {

Callers 1

apply_conf_changeMethod · 0.80

Calls 5

get_mutMethod · 0.45
iterMethod · 0.45
removeMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected