Exemple #1
0
 /**
  * Adds a peer to the set. If a peer reaches the bag size, the class is reported to the
  * oversizebag. Furthermore, it notifies listeners about an insert.
  *
  * @param map The set to add the peer
  * @param remotePeer The remote peer to add
  * @param classMember The class member, which is used to report oversize.
  * @return True if the peer could be added. If the peer is already in, it returns false
  */
 private boolean insertOrUpdate(
     final Map<Number160, PeerAddress> map, final PeerAddress remotePeer, final int classMember) {
   boolean retVal;
   synchronized (map) {
     retVal = !map.containsKey(remotePeer.getID());
     map.put(remotePeer.getID(), remotePeer);
   }
   if (retVal) {
     peerCount.incrementAndGet();
     notifyInsert(remotePeer);
   } else {
     notifyUpdate(remotePeer);
   }
   return retVal;
 }