Skip to content

Commit

Permalink
Merge pull request #3852 from wiz/fix-block-explorer-validity-check
Browse files Browse the repository at this point in the history
Check existence of selected block explorer using name string comparison
  • Loading branch information
ripcurlx authored Jan 3, 2020
2 parents 4ac5450 + c078320 commit 5883f70
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/src/main/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,12 @@ public void readPersisted() {

// if no valid Bitcoin block explorer is set, select the 1st valid Bitcoin block explorer
ArrayList<BlockChainExplorer> btcExplorers = getBlockChainExplorers();
BlockChainExplorer btcExplorer = getBlockChainExplorer();
if (btcExplorer == null || btcExplorers.contains(btcExplorer) == false)
if (!blockExplorerExists(btcExplorers, getBlockChainExplorer()))
setBlockChainExplorer(btcExplorers.get(0));

// if no valid BSQ block explorer is set, randomly select a valid BSQ block explorer
ArrayList<BlockChainExplorer> bsqExplorers = getBsqBlockChainExplorers();
BlockChainExplorer bsqExplorer = getBsqBlockChainExplorer();
if (bsqExplorer == null || bsqExplorers.contains(bsqExplorer) == false)
if (!blockExplorerExists(bsqExplorers, getBsqBlockChainExplorer()))
setBsqBlockChainExplorer(bsqExplorers.get((new Random()).nextInt(bsqExplorers.size())));

tradeCurrenciesAsObservable.addAll(prefPayload.getFiatCurrencies());
Expand Down Expand Up @@ -826,6 +824,16 @@ else if (change.wasRemoved() && change.getRemovedSize() == 1 && initialReadDone)
tradeCurrenciesAsObservable.remove(change.getRemoved().get(0));
}

private boolean blockExplorerExists(ArrayList<BlockChainExplorer> explorers,
BlockChainExplorer explorer)
{
if (explorer != null && explorers != null && explorers.size() > 0)
for (int i = 0; i < explorers.size(); i++)
if (explorers.get(i).name.equals(explorer.name))
return true;
return false;
}

private interface ExcludesDelegateMethods {
void setTacAccepted(boolean tacAccepted);

Expand Down

0 comments on commit 5883f70

Please sign in to comment.