Skip to content

Commit

Permalink
Merge pull request #185 from kennycud/master
Browse files Browse the repository at this point in the history
Server Info Current Server & Ordering
  • Loading branch information
crowetic authored Mar 25, 2024
2 parents cc740cc + e83b226 commit d54f840
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/java/org/qortal/api/resource/CrossChainUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
import org.qortal.repository.DataException;
import org.qortal.repository.Repository;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;


Expand All @@ -31,10 +26,21 @@ public class CrossChainUtils {
public static ServerConfigurationInfo buildServerConfigurationInfo(Bitcoiny blockchain) {

BitcoinyBlockchainProvider blockchainProvider = blockchain.getBlockchainProvider();

// the only reason this is called is to ensure the current server is set on the blockchain provider,
// if there is an exception, then ignore it
try {
blockchainProvider.getCurrentHeight();
} catch (ForeignBlockchainException e) {
LOGGER.warn("Problems getting block height before building server configuration infos");
}

ChainableServer currentServer = blockchainProvider.getCurrentServer();

return new ServerConfigurationInfo(
buildInfos(blockchainProvider.getServers(), currentServer),
buildInfos(blockchainProvider.getServers(), currentServer).stream()
.sorted(Comparator.comparing(ServerInfo::isCurrent).reversed())
.collect(Collectors.toList()),
buildInfos(blockchainProvider.getRemainingServers(), currentServer),
buildInfos(blockchainProvider.getUselessServers(), currentServer)
);
Expand Down

0 comments on commit d54f840

Please sign in to comment.