public ConnectionState GetReplacement(ConnectionTableState cts, Connection c, ConnectionState c1, ConnectionState c2) { BT.TransportAddress.TAType c1type = c1.Edge.TAType; BT.TransportAddress.TAType c2type = c2.Edge.TAType; if (c1type != c2type) { return(_fallback.GetReplacement(cts, c, c1, c2)); } if (c1type == BT.TransportAddress.TAType.Udp) { return(GetUdpIdx(c1) <= GetUdpIdx(c2) ? c1 : c2); } else if (c1type == BT.TransportAddress.TAType.Tcp) { return(GetTcpIdx(c1) <= GetTcpIdx(c2) ? c1 : c2); } else { //We don't know how to handle, move on: return(_fallback.GetReplacement(cts, c, c1, c2)); } }
public ConnectionState GetReplacement(ConnectionTableState cts, Connection c, ConnectionState c1, ConnectionState c2) { /* * Now we are deciding between two edges of the same * type, and therefore, it is fundamentally arbitrary. * HOWEVER: both sides of the Connection should agree * on the computation, OR one could choose one edge, * and the other the opposite. */ bool c1_is_down = IsDownhill(c.Address, c1); bool c2_is_down = IsDownhill(c.Address, c2); if (c1_is_down && (false == c2_is_down)) { return(c1); } if (c2_is_down && (false == c1_is_down)) { return(c2); } //We don't know how to handle, move on: return(_fallback.GetReplacement(cts, c, c1, c2)); }
public ConnectionState GetReplacement(ConnectionTableState cts, Connection c, ConnectionState c1, ConnectionState c2) { if ((c1.Edge is RelayEdge) && (c2.Edge is RelayEdge)) { return(GetIdx(c1) <= GetIdx(c2) ? c1 : c2); } return(_fallback.GetReplacement(cts, c, c1, c2)); }
public ConnectionState GetReplacement(ConnectionTableState cts, Connection c, ConnectionState c1, ConnectionState c2) { int tcmp = _tc.Compare(c1.Edge.TAType, c2.Edge.TAType); if (tcmp < 0) { return(c1); } else if (tcmp > 0) { return(c2); } else { //We don't know how to handle, move on: return(_fallback.GetReplacement(cts, c, c1, c2)); } }