Ejemplo n.º 1
0
 /**
  * Gets the next query based on the search mode. If for some reason the search mode is not
  * defined, this returns the easiest query.
  *
  * @since v1.3.0
  */
 private RegexQuery getNextQuery() {
   RegexQuery query;
   if (searchMode == SearchMode.EASIEST_HARDEST) {
     query = pool.getEasiestQuery();
   } else if (searchMode == SearchMode.HARDEST_EASIEST) {
     query = pool.getHardestQuery();
   } else if (searchMode == SearchMode.SHORTEST_LONGEST) {
     query = pool.getShortestQuery();
   } else if (searchMode == SearchMode.LONGEST_SHORTEST) {
     query = pool.getLongestQuery();
   } else {
     query = pool.getEasiestQuery();
   }
   return query;
 }
Ejemplo n.º 2
0
 public PoolSearch build() {
   if (netParams == null) {
     netParams = pool.getNetwork().toGlobalNetParams();
   }
   if (searchMode == null) {
     searchMode = SearchMode.SEARCH_ALL;
   }
   return new PoolSearch(this);
 }
Ejemplo n.º 3
0
 @Override
 public void onQueryRemoved(RegexQuery query) {
   boolean forceStopAll = !pool.containsQueries();
   synchronized (poolSearchReferences) {
     for (PoolSearch search : poolSearchReferences) {
       search.isSearching = false;
       search.forceStop = forceStopAll;
     }
   }
 }
Ejemplo n.º 4
0
 private void searchAll() {
   ECKey key;
   RegexQuery query;
   long localGen;
   while (!(forceStop || threadKilled())) {
     key = new ECKey();
     localGen = ++generated;
     if ((query = pool.matches(key, netParams)) != null) {
       addressFound(
           key, query.getNetworkParameters(netParams), generated, getGeneratedPerSecond(), query);
       if (!query.isFindUnlimited()) {
         pool.removeQuery(query);
       }
     }
     if (canBurstUpdate(localGen)) {
       burstGenerated(generated, updateAmount, getGeneratedPerSecond());
     }
   }
 }
Ejemplo n.º 5
0
 @Override
 public void run() {
   pool.registerListener(this);
   setStartTimeToNow();
   switch (searchMode) {
     case SEARCH_ALL:
       searchAll();
       break;
     case EASIEST_HARDEST:
     case HARDEST_EASIEST:
     case SHORTEST_LONGEST:
     case LONGEST_SHORTEST:
       customSearch();
       break;
   }
   if (!pool.containsQueries()) {
     taskCompleted(generated, getGeneratedPerSecond());
   }
   pool.unregisterListener(this);
 }
Ejemplo n.º 6
0
 private void customSearch() {
   RegexQuery query = getNextQuery();
   if (query == null) return;
   ECKey key;
   long localGen;
   isSearching = true;
   while (isSearching && !threadKilled()) {
     key = new ECKey();
     localGen = ++generated;
     if (query.matches(key, netParams)) {
       addressFound(key, netParams, localGen, getGeneratedPerSecond(), query);
       pool.removeQuery(query);
       break;
     }
     if (canBurstUpdate(localGen)) {
       burstGenerated(localGen, updateAmount, getGeneratedPerSecond());
     }
   }
   if (!forceStop) {
     customSearch();
   }
 }