virtual public void UpdateRemoteTAs(IList<TransportAddress> tas_to_add)
{
IList<TransportAddress> local_tas = LocalTAs;
lock(_sync) {
// Remove duplicates in tas_to_add
var dup_test = new Dictionary<TransportAddress, bool>();
foreach(TransportAddress ta in tas_to_add) {
if(dup_test.ContainsKey(ta) || local_tas.Contains(ta)) {
continue;
}
dup_test.Add(ta, true);
}
// Remove duplicates found in tas_to_add and _remote_ta. If we don't,
// we could be flooded by a single node and lose track of good TAs.
foreach(TransportAddress ta in _remote_ta) {
if(dup_test.ContainsKey(ta)) {
dup_test.Remove(ta);
}
}
// Add in the remaining TAs
foreach(TransportAddress ta in dup_test.Keys) {
_remote_ta = _remote_ta.PushIntoNew(ta);
}
// Remove older TAs after _MAX_RECORDED_TAS
int count = _remote_ta.Count;
if(count > _MAX_RECORDED_TAS) {
for(int i = _MAX_RECORDED_TAS; i < count; i++) {
_remote_ta = _remote_ta.RemoveAtFromNew(_MAX_RECORDED_TAS);
}
}
}
}