Brunet.Symphony.StructuredNearConnectionOverlord.TrimConnections C# (CSharp) Метод

TrimConnections() защищенный Метод

protected TrimConnections ( ) : void
Результат void
    protected void TrimConnections() {
      ConnectionTable tab = _node.ConnectionTable;
      ConnectionList cons = tab.GetConnections(ConnectionType.Structured);
      ArrayList trim_candidates = new ArrayList();
      foreach(Connection c in cons) {
        if(!c.ConType.Equals(STRUC_NEAR)) {
          continue;
        }

        int left_pos = cons.LeftInclusiveCount(_node.Address, c.Address);
        int right_pos = cons.RightInclusiveCount(_node.Address, c.Address);

        if( right_pos >= 2 * DESIRED_NEIGHBORS && left_pos >= 2 * DESIRED_NEIGHBORS ) {
          //These are near neighbors that are not so near
          trim_candidates.Add(c);
        }
      }

      if(trim_candidates.Count == 0) {
        return;
      }

      //Delete a farthest trim candidate:
      BigInteger biggest_distance = new BigInteger(0);
      BigInteger tmp_distance = new BigInteger(0);
      Connection to_trim = null;
      foreach(Connection tc in trim_candidates ) 
      {
        AHAddress t_ah_add = (AHAddress)tc.Address;
        tmp_distance = t_ah_add.DistanceTo( (AHAddress)_node.Address).abs();
        if (tmp_distance > biggest_distance) {
          biggest_distance = tmp_distance;
          //Console.Error.WriteLine("...finding far distance for trim: {0}",biggest_distance.ToString() );
          to_trim = tc;
        }
      }

#if POB_DEBUG
        Console.Error.WriteLine("Attempt to trim Near: {0}", to_trim);
#endif
       to_trim.Close(_node.Rpc, "SCO, near connection trim" );
    }
  }