public List<KeyRegistrationRecord> getRandomPeers( final String inBase64Key, final int inDesired, final int inMax, boolean updateRefreshTime ) {
		
		if( isRegistered(inBase64Key) == false ) {
			return null;
		}
		
		if( updateRefreshTime ) {
			updateRefreshTime(inBase64Key);
		}
		
		/**
		 * First retrieve any existing friends. 
		 */
		KeyRegistrationRecord me = key_to_record.get(inBase64Key);
		logger.finer("Get random peers for: " + me.getNickname());
		
		Set<KeyRegistrationRecord> friends = topology.get(me);
		logger.finer("\t" + friends.size() + " existing random peers in topo");
		
		
		/**
		 * Peering policy is to add friends on request until exceeding Max(85% of inNumber, 5). 
		 * The goal here is to avoid having strongly connected components that cannot be broken into by new peers, so we 
		 * always keep a few slots open for the most recent joiner (churn introduces some mixing as well) 
		 */
		long start = System.currentTimeMillis();
		KeyRegistrationRecord [] candidates = peers.toArray(new KeyRegistrationRecord[0]);
		Collections.shuffle(Arrays.asList(candidates));
		logger.finest("\tShuffled " + candidates.length + " candidates in " + (System.currentTimeMillis() - start));
		for( KeyRegistrationRecord candidate : candidates ) {
			// have we found enough?
			if( friends.size() > Math.max(0.85 * (double)inDesired, 5) ) {
				break;
			}
			
			// skip friends already in the set
			if( friends.contains(candidate) ) {
				continue;
			}
			
			// skip ourselves
			if( candidate.equals(me) ) {
				continue;
			}
			
			// candidate is already past the maximum number allowed
			if( topology.get(candidate).size() > inMax ) {
				logger.finest("\tCandidate: " + candidate.getNickname() + " has too many: " + topology.get(candidate).size());
				continue;
			} 
			
			/** 
			 * success -- add to output and store in DB. Since we're returning the topology list directly, we 
			 * don't need an extra copy here
			 */
			logger.finest("\tAdding candidate: " + candidate.getNickname() + " with " + topology.get(candidate).size());
			createFriendLink(topology, me, candidate, true);
		}
		
		logger.finer("Returning " + friends.size() + " for " + me.getNickname());
		return Arrays.asList(friends.toArray(new KeyRegistrationRecord[0]));
	}