protected void CreateShortcutCallback(Address start, SortedList score_table, Address current) {
if (score_table.Count > 0) {
/**
* we remember our address and the start of range inside the token.
* token is the concatenation of
* (a) local node address
* (b) random target for the range queried by target selector
*/
string token = _node.Address + start.ToString();
//connect to the min_target
Address min_target = (Address) score_table.GetByIndex(0);
ISender send = null;
if (start.Equals(min_target)) {
//looks like the target selector simply returned our random address
#if TRACE
if (ProtocolLog.SCO.Enabled) {
ProtocolLog.Write(ProtocolLog.SCO,
String.Format("SCO local: {0}, Connecting (shortcut) to min_target: {1} (greedy), random_target: {2}.",
_node.Address, min_target, start));
}
#endif
//use a greedy sender
send = new AHGreedySender(_node, min_target);
} else {
#if TRACE
if (ProtocolLog.SCO.Enabled) {
ProtocolLog.Write(ProtocolLog.SCO,
String.Format("SCO local: {0}, Connecting (shortcut) to min_target: {1} (exact), random_target: {2}.",
_node.Address, min_target, start));
}
#endif
//use exact sender
send = new AHExactSender(_node, min_target);
}
ConnectTo(send, min_target, STRUC_SHORT, token);
}
}