public int Leader_GetActionsCompletedCount(string peerID) { lock (_action_lock) { if (!ActionsCompleted.ContainsKey(peerID)) { return(0); } return(ActionsCompleted[peerID].Count); } }
public void ClearPeerLog(string peerID) { lock (_batch_lock) { if (BatchesBehind.ContainsKey(peerID)) { BatchesBehind.Remove(peerID); } } lock (_action_lock) { if (ActionsCompleted.ContainsKey(peerID)) { ActionsCompleted.Remove(peerID); } } }
public void Leader_RemoveActionsCompleted(string peerID, string action) { lock (_action_lock) { if (ActionsCompleted.ContainsKey(peerID)) { if (ActionsCompleted[peerID].Contains(action)) { ActionsCompleted[peerID].Remove(action); } // Logger.Write(Logger.Tag.INFO, "Removed " + action.Substring(0,10) +"... from " + peerID); } else { ActionsCompleted.Add(peerID, new HashSet <string>()); } } }
public HashSet <string> Leader_GetActionsCompleted(string peerID) { lock (_action_lock) { if (!ActionsCompleted.ContainsKey(peerID)) { return(new HashSet <string>()); } HashSet <string> behind = new HashSet <string>(); foreach (string s in ActionsCompleted[peerID].ToList()) { if (!behind.Contains(s) && behind.Count < 10) { behind.Add(s); } } return(behind); } }