From 37d173c7a92c7e8a13f219a0984cdf45b3d013e0 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Sun, 28 Jul 2024 19:29:22 +0700 Subject: [PATCH] Remove 404State. Merge changes from master (excl. removal of devinBilek nodes) Signed-off-by: HenrikJannsen --- .github/workflows/build.yml | 2 +- .github/workflows/codacy-coverage-reporter.yml | 2 +- .../main/java/bisq/core/dao/state/DaoStateService.java | 2 ++ .../main/java/bisq/core/user/AutoConfirmSettings.java | 4 +++- core/src/main/java/bisq/core/user/Preferences.java | 10 +++++++++- inventory/src/main/resources/inv_btc_mainnet.seednodes | 4 ---- .../java/bisq/restapi/endpoints/ExplorerBlocksApi.java | 5 ++++- .../java/bisq/restapi/endpoints/ExplorerDaoApi.java | 5 ++++- .../restapi/endpoints/ExplorerTransactionsApi.java | 2 ++ 9 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ebb9672b1c..60cc27a7dbe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,6 @@ jobs: distribution: 'zulu' - name: Build with Gradle - uses: gradle/gradle-build-action@v3.4.2 + uses: gradle/gradle-build-action@v3.5.0 with: arguments: build --scan diff --git a/.github/workflows/codacy-coverage-reporter.yml b/.github/workflows/codacy-coverage-reporter.yml index 5319366c0aa..14615dd3d3d 100644 --- a/.github/workflows/codacy-coverage-reporter.yml +++ b/.github/workflows/codacy-coverage-reporter.yml @@ -22,7 +22,7 @@ jobs: distribution: 'zulu' - name: Build with Gradle - uses: gradle/gradle-build-action@v3.4.2 + uses: gradle/gradle-build-action@v3.5.0 with: arguments: build jacocoTestReport testCodeCoverageReport --scan diff --git a/core/src/main/java/bisq/core/dao/state/DaoStateService.java b/core/src/main/java/bisq/core/dao/state/DaoStateService.java index 3f4ee711c2e..90e2df9af86 100644 --- a/core/src/main/java/bisq/core/dao/state/DaoStateService.java +++ b/core/src/main/java/bisq/core/dao/state/DaoStateService.java @@ -1055,6 +1055,7 @@ public Map> getTxIdSetByAddress() { tx.getTxOutputs().stream() .filter(this::isBsqTxOutputType) .filter(txOutput -> txOutput.getAddress() != null) + .filter(txOutput -> !txOutput.getAddress().isEmpty()) .forEach(txOutput -> { String address = txOutput.getAddress(); Set txIdSet = cachedTxIdSetByAddress.getOrDefault(address, new HashSet<>()); @@ -1071,6 +1072,7 @@ public Map> getTxIdSetByAddress() { getUnorderedTxOutputStream() .filter(this::isBsqTxOutputType) .filter(txOutput -> txOutput.getAddress() != null) + .filter(txOutput -> !txOutput.getAddress().isEmpty()) .forEach(txOutput -> { String txId = txIdByConnectedTxOutputKey.get(txOutput.getKey()); if (txId != null) { diff --git a/core/src/main/java/bisq/core/user/AutoConfirmSettings.java b/core/src/main/java/bisq/core/user/AutoConfirmSettings.java index f94e0538492..742e9f5e656 100644 --- a/core/src/main/java/bisq/core/user/AutoConfirmSettings.java +++ b/core/src/main/java/bisq/core/user/AutoConfirmSettings.java @@ -29,8 +29,10 @@ import java.util.concurrent.CopyOnWriteArrayList; import lombok.Getter; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; +@ToString @Slf4j @Getter public final class AutoConfirmSettings implements PersistablePayload { @@ -43,7 +45,7 @@ public interface Listener { private long tradeLimit; private List serviceAddresses; private String currencyCode; - private List listeners = new CopyOnWriteArrayList<>(); + private final List listeners = new CopyOnWriteArrayList<>(); @SuppressWarnings("SameParameterValue") static Optional getDefault(List serviceAddresses, String currencyCode) { diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index 79f387b368a..85c0d932ed0 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -378,12 +378,20 @@ private void setupPreferences() { setUsePriceNotifications(true); } - if (prefPayload.getAutoConfirmSettingsList().isEmpty()) { + // Remove retired XMR AutoConfirm address + var doApplyDefaults = prefPayload.getAutoConfirmSettingsList().stream() + .map(autoConfirmSettings -> autoConfirmSettings.getServiceAddresses().stream() + .anyMatch(address -> address.contains("monero3bec7m26vx6si6qo7q7imlaoz45ot5m2b5z2ppgoooo6jx2rqd"))) + .findAny() + .orElse(true); + if (doApplyDefaults) { + prefPayload.getAutoConfirmSettingsList().clear(); List defaultXmrTxProofServices = getDefaultXmrTxProofServices(); AutoConfirmSettings.getDefault(defaultXmrTxProofServices, "XMR") .ifPresent(xmrAutoConfirmSettings -> { getAutoConfirmSettingsList().add(xmrAutoConfirmSettings); }); + persistenceManager.forcePersistNow(); } // We set the capability in CoreNetworkCapabilities if the program argument is set. diff --git a/inventory/src/main/resources/inv_btc_mainnet.seednodes b/inventory/src/main/resources/inv_btc_mainnet.seednodes index 064c932264c..6e9ac86fe27 100644 --- a/inventory/src/main/resources/inv_btc_mainnet.seednodes +++ b/inventory/src/main/resources/inv_btc_mainnet.seednodes @@ -1,8 +1,4 @@ # Expected format: nodeaddress.onion:port (@owner) -# removed in 1.9.16 -sn4o3kdfxz6pidvafxv5i5dv3jrk6twtptm7s7wchwwwb5xy37y4x5id.onion:8000 (@403State) -sn4o3s5peekvk333vkrguw3gmd6mfy6bawynejslcnva2ibdbdrxakyd.onion:8000 (@403State) -sn4o3zbnlnivbolvsgzapzmfzh6q27z5owrhqbxjlhmcsfrvbo2rd2ad.onion:8000 (@403State) # from 1.9.15, to be removed in 1.9.18 devinv3rhon24gqf5v6ondoqgyrbzyqihzyouzv7ptltsewhfmox2zqd.onion:8000 (@devinbileck) devinsn2teu33efff62bnvwbxmfgbfjlgqsu3ad4b4fudx3a725eqnyd.onion:8000 (@devinbileck) diff --git a/restapi/src/main/java/bisq/restapi/endpoints/ExplorerBlocksApi.java b/restapi/src/main/java/bisq/restapi/endpoints/ExplorerBlocksApi.java index f7b159698ee..2d65506f104 100644 --- a/restapi/src/main/java/bisq/restapi/endpoints/ExplorerBlocksApi.java +++ b/restapi/src/main/java/bisq/restapi/endpoints/ExplorerBlocksApi.java @@ -36,9 +36,10 @@ @Tag(name = "BLOCKS API") public class ExplorerBlocksApi { private final DaoStateService daoStateService; + private final RestApi restApi; public ExplorerBlocksApi(@Context Application application) { - RestApi restApi = ((RestApiMain) application).getRestApi(); + restApi = ((RestApiMain) application).getRestApi(); daoStateService = restApi.getDaoStateService(); } @@ -51,6 +52,7 @@ public ExplorerBlocksApi(@Context Application application) { @GET @Path("get-bsq-block-by-height/{block-height}") public JsonBlock getBsqBlockByHeight(@Parameter(description = "Block Height") @PathParam("block-height") int blockHeight) { + restApi.checkDaoReady(); List blocks = daoStateService.getBlocks(); Optional jsonBlock = checkNotNull(blocks.stream()) .filter(block -> block.getHeight() == blockHeight) @@ -68,6 +70,7 @@ public JsonBlock getBsqBlockByHeight(@Parameter(description = "Block Height") @P @GET @Path("get-bsq-block-by-hash/{block-hash}") public JsonBlock getBsqBlockByHash(@Parameter(description = "Block Hash") @PathParam("block-hash") String hash) { + restApi.checkDaoReady(); List blocks = daoStateService.getBlocks(); Optional jsonBlock = checkNotNull(blocks.stream()) .filter(block -> block.getHash().equalsIgnoreCase(hash)) diff --git a/restapi/src/main/java/bisq/restapi/endpoints/ExplorerDaoApi.java b/restapi/src/main/java/bisq/restapi/endpoints/ExplorerDaoApi.java index 662a9b4e034..8c761cd138e 100644 --- a/restapi/src/main/java/bisq/restapi/endpoints/ExplorerDaoApi.java +++ b/restapi/src/main/java/bisq/restapi/endpoints/ExplorerDaoApi.java @@ -41,9 +41,10 @@ public class ExplorerDaoApi { private final DaoFacade daoFacade; private final ProposalService proposalService; private final CycleService cycleService; + private final RestApi restApi; public ExplorerDaoApi(@Context Application application) { - RestApi restApi = ((RestApiMain) application).getRestApi(); + restApi = ((RestApiMain) application).getRestApi(); daoStateService = restApi.getDaoStateService(); proposalService = restApi.getProposalService(); cycleService = restApi.getCycleService(); @@ -54,6 +55,7 @@ public ExplorerDaoApi(@Context Application application) { @GET @Path("get-bsq-stats") public BsqStatsDto getBsqStats() { + restApi.checkDaoReady(); long genesisSupply = daoFacade.getGenesisTotalSupply().getValue(); long issuedByCompensations = daoStateService.getIssuanceSetForType(IssuanceType.COMPENSATION).stream().mapToLong(Issuance::getAmount).sum(); long issuedByReimbursements = daoStateService.getIssuanceSetForType(IssuanceType.REIMBURSEMENT).stream().mapToLong(Issuance::getAmount).sum(); @@ -70,6 +72,7 @@ public BsqStatsDto getBsqStats() { @GET @Path("query-dao-cycles") public List queryDaoCycles() { + restApi.checkDaoReady(); Set cyclesAdded = new HashSet<>(); List result = new ArrayList<>(); // Creating our data structure is a bit expensive so we ensure to only create the CycleListItems once. diff --git a/restapi/src/main/java/bisq/restapi/endpoints/ExplorerTransactionsApi.java b/restapi/src/main/java/bisq/restapi/endpoints/ExplorerTransactionsApi.java index 8d1aa4ca811..3ce58aabdf9 100644 --- a/restapi/src/main/java/bisq/restapi/endpoints/ExplorerTransactionsApi.java +++ b/restapi/src/main/java/bisq/restapi/endpoints/ExplorerTransactionsApi.java @@ -64,6 +64,7 @@ public ExplorerTransactionsApi(@Context Application application) { @Path("get-bsq-tx/{txid}") public JsonTx getTx(@Parameter(description = "TxId") @PathParam("txid") String txId) { + restApi.checkDaoReady(); Optional jsonTx = daoStateService.getUnorderedTxStream() .filter(t -> t.getId().equals(txId)) .map(tx -> BlockDataToJsonConverter.getJsonTx(daoStateService, tx)) @@ -101,6 +102,7 @@ public List getBisqTxForAddr(@PathParam("addr") String address) { public List queryTxsPaginated(@PathParam("start") int start, @PathParam("count") int count, @PathParam("filters") String filters) { + restApi.checkDaoReady(); log.info("filters: {}", filters); List jsonTxs = daoStateService.getUnorderedTxStream() .sorted(Comparator.comparing(BaseTx::getTime).reversed())