protected void CheckBypassCallback(Address start, SortedList score_table, Address bp_address) {
if (ProtocolLog.SCO.Enabled) {
ProtocolLog.Write(ProtocolLog.SCO,
String.Format("SCO local: {0}, Checking bypass optimality.",
_node.Address));
}
ArrayList bypass_cons = new ArrayList();
foreach(Connection c in _node.ConnectionTable.GetConnections(STRUC_BYPASS) ) {
string token = c.State.PeerLinkMessage.Token;
if(token == null || token.Equals(_node.Address.ToString())) {
continue;
}
bypass_cons.Add(c);
}
int max_rank = bypass_cons.Count > 1 ? 0: (int) Math.Ceiling(0.2*score_table.Count);
foreach (Connection bp in bypass_cons) {
if (!IsConnectionOptimal(bp.Address, score_table, max_rank)) {
Address min_target = (Address) score_table.GetByIndex(0);
#if TRACE
if (ProtocolLog.SCO.Enabled) {
ProtocolLog.Write(ProtocolLog.SCO,
String.Format("SCO local: {0}, Trimming bypass : {1}, min_target: {2}.",
_node.Address, bp.Address, min_target));
}
#endif
lock(_sync) {
double total_secs = (DateTime.UtcNow - bp.CreationTime).TotalSeconds;
_sum_con_lifetime += total_secs;
_trim_count++;
}
bp.Close(_node.Rpc, String.Empty);
#if TRACE
} else if (ProtocolLog.SCO.Enabled) {
ProtocolLog.Write(ProtocolLog.SCO,
String.Format("SCO local: {0}, Bypass is optimal: {1}.",
_node.Address, bp));
#endif
}
}
}