diff --git a/duniter4j-client/pom.xml b/duniter4j-client/pom.xml index d559dbaec338653ac6b347426019cdd457421405..93e31e27980f7411574a0e7446c3ea682ee85c6a 100644 --- a/duniter4j-client/pom.xml +++ b/duniter4j-client/pom.xml @@ -3,7 +3,7 @@ <parent> <artifactId>duniter4j</artifactId> <groupId>org.duniter</groupId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/duniter4j-core-client/pom.xml b/duniter4j-core-client/pom.xml index fc68805829f20c6d385ab983f12e0322f77a187c..79b20dddef09478b351b117d552e516b5271fcd6 100644 --- a/duniter4j-core-client/pom.xml +++ b/duniter4j-core-client/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter</groupId> <artifactId>duniter4j</artifactId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> </parent> <artifactId>duniter4j-core-client</artifactId> diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java index d022ca0ac5662fdc5affa7f02fdd3476d2506986..98037a065be8a861073f5e1658858bb51098d07f 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/model/bma/BlockchainParameters.java @@ -132,6 +132,11 @@ public class BlockchainParameters implements Serializable{ */ private Integer dtDiffEval; + /** + * The number of previous blocks to check for personalized difficulty + */ + @Deprecated + private Integer blocksRot; /** * The percent of previous issuers to reach for personalized difficulty @@ -251,6 +256,16 @@ public class BlockchainParameters implements Serializable{ this.dtDiffEval = dtDiffEval; } + @Deprecated + public Integer getBlocksRot() { + return blocksRot; + } + + @Deprecated + public void setBlocksRot(Integer blocksRot) { + this.blocksRot = blocksRot; + } + public Double getPercentRot() { return percentRot; } diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/HttpServiceImpl.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/HttpServiceImpl.java index dbdb1ab496d2a9de73e2156c491385a40ce6abaf..892557eeb07fcaa1182993a7b840583026b2455d 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/HttpServiceImpl.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/HttpServiceImpl.java @@ -348,6 +348,9 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean catch (SocketTimeoutException | ConnectTimeoutException e) { throw new HttpTimeoutException(I18n.t("duniter4j.client.core.timeout"), e); } + catch (TechnicalException e) { + throw e; + } catch (Throwable e) { throw new TechnicalException(e.getMessage(), e); } diff --git a/duniter4j-core-shared/pom.xml b/duniter4j-core-shared/pom.xml index 9c505c796c344da823941b1c2f968268a9ac553b..46ec23eeaa1a907d6bf3500f796a07d7ab947192 100644 --- a/duniter4j-core-shared/pom.xml +++ b/duniter4j-core-shared/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter</groupId> <artifactId>duniter4j</artifactId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> </parent> <artifactId>duniter4j-core-shared</artifactId> diff --git a/duniter4j-es-assembly/pom.xml b/duniter4j-es-assembly/pom.xml index 9b2e24372bcd30cf4f62dea49fed18b9221066bc..66c799d12e15b31989c1f6f5153d4492782bc2dd 100644 --- a/duniter4j-es-assembly/pom.xml +++ b/duniter4j-es-assembly/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter</groupId> <artifactId>duniter4j</artifactId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> </parent> <artifactId>duniter4j-es-assembly</artifactId> diff --git a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml index f199e0f039ebf51b737932e2bee2fb5d98db7b5c..689c8b9416cfb495a8f88afbb85fd175dea1d92d 100644 --- a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml +++ b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml @@ -157,7 +157,7 @@ duniter.security.enable: true # # Should synchronize data from an existing ES node ? # -duniter.data.sync.enable: true +duniter.data.sync.enable: false #duniter.data.sync.enable: true duniter.data.sync.host: g1.data.duniter.fr duniter.data.sync.port: 443 @@ -166,7 +166,7 @@ duniter.data.sync.port: 443 # # Enable mail module ? # -duniter.mail.enable: true +duniter.mail.enable: false # # Mail: SMTP server configuration (host and port) # diff --git a/duniter4j-es-assembly/src/test/es-home/config/logging.yml b/duniter4j-es-assembly/src/test/es-home/config/logging.yml index aa49d8762e7d0018183016ebc26469f7305d98f0..b9122182159af75a55cfd869c89af8e2a84d13ca 100644 --- a/duniter4j-es-assembly/src/test/es-home/config/logging.yml +++ b/duniter4j-es-assembly/src/test/es-home/config/logging.yml @@ -15,6 +15,7 @@ logger: com.amazonaws.metrics.AwsSdkMetrics: ERROR duniter: DEBUG + duniter.core: DEBUG duniter.security: ERROR duniter.user.event: INFO duniter.network.p2p: INFO diff --git a/duniter4j-es-core/pom.xml b/duniter4j-es-core/pom.xml index 80353545c8b5734ce7eb5454da8e0e61afdba977..e3741db754d1d8b761862456354121656cbe712c 100644 --- a/duniter4j-es-core/pom.xml +++ b/duniter4j-es-core/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter</groupId> <artifactId>duniter4j</artifactId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> </parent> <artifactId>duniter4j-es-core</artifactId> diff --git a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginInit.java b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginInit.java index 44b58d8db750f26cf7a91afaf9e91c9faed0cc76..3ea14f071c6fa2f038911f979e3c5946cee33dd2 100644 --- a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginInit.java +++ b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginInit.java @@ -118,64 +118,78 @@ public class PluginInit extends AbstractLifecycleComponent<PluginInit> { // Synchronize blockchain if (pluginSettings.enableBlockchain()) { + Peer peer = pluginSettings.checkAndGetPeer(); - // Index (or refresh) node's currency - final Currency currency = injector.getInstance(CurrencyService.class) - .indexCurrencyFromPeer(peer, true); + Currency currency; + try { + // Index (or refresh) node's currency + currency = injector.getInstance(CurrencyService.class) + .indexCurrencyFromPeer(peer, true); + } catch(Throwable e){ + logger.error(String.format("Error while indexing currency. Skipping blockchain indexation.", e.getMessage()), e); + throw e; + } + final String currencyName = currency.getCurrencyName(); if (logger.isInfoEnabled()) { - logger.info(String.format("[%s] Indexing blockchain...", currency.getCurrencyName())); + logger.info(String.format("[%s] Indexing blockchain...", currencyName)); } + // Add access security rules, for the currency indices injector.getInstance(RestSecurityController.class) // Add access to <currency>/block index .allowIndexType(RestRequest.Method.GET, - currency.getCurrencyName(), + currencyName, BlockDao.TYPE) .allowPostSearchIndexType( - currency.getCurrencyName(), + currencyName, BlockDao.TYPE) // Add access to <currency>/blockStat index .allowIndexType(RestRequest.Method.GET, - currency.getCurrencyName(), + currencyName, BlockStatDao.TYPE) .allowPostSearchIndexType( - currency.getCurrencyName(), + currencyName, BlockStatDao.TYPE) // Add access to <currency>/peer index .allowIndexType(RestRequest.Method.GET, - currency.getCurrencyName(), + currencyName, PeerDao.TYPE) .allowPostSearchIndexType( - currency.getCurrencyName(), + currencyName, PeerDao.TYPE) // Add access to <currency>/movement index .allowIndexType(RestRequest.Method.GET, - currency.getCurrencyName(), + currencyName, MovementDao.TYPE) .allowPostSearchIndexType( - currency.getCurrencyName(), + currencyName, MovementDao.TYPE); // Wait end of currency index creation, then index blocks threadPool.scheduleOnClusterHealthStatus(() -> { - // Index blocks (and listen if new block appear) - injector.getInstance(BlockchainService.class) - .indexLastBlocks(peer) - .listenAndIndexNewBlock(peer); - - // Index peers (and listen if new peer appear) - injector.getInstance(PeerService.class) - .listenAndIndexPeers(peer); - - if (logger.isInfoEnabled()) { - logger.info(String.format("[%s] Indexing blockchain [OK]", currency.getCurrencyName())); + try { + // Index blocks (and listen if new block appear) + injector.getInstance(BlockchainService.class) + .indexLastBlocks(peer) + .listenAndIndexNewBlock(peer); + + // Index peers (and listen if new peer appear) + injector.getInstance(PeerService.class) + .listenAndIndexPeers(peer); + + if (logger.isInfoEnabled()) { + logger.info(String.format("[%s] Indexing blockchain [OK]", currencyName)); + } + } catch(Throwable e){ + logger.error(String.format("[%s] Indexing blockchain error: %s", currencyName, e.getMessage()), e); + throw e; } }, ClusterHealthStatus.YELLOW, ClusterHealthStatus.GREEN); diff --git a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/service/CurrencyService.java b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/service/CurrencyService.java index dbe90837f716c1cc882caf5e70bd6e1c2eca89f2..9511aee0ce83ea7ee26a80b8aed4dc1b3d3ced86 100644 --- a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/service/CurrencyService.java +++ b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/service/CurrencyService.java @@ -95,7 +95,9 @@ public class CurrencyService extends AbstractService { * @return the created blockchain */ public Currency indexCurrencyFromPeer(Peer peer, boolean autoReconnect) { - if (!autoReconnect) return indexCurrencyFromPeer(peer); + if (!autoReconnect) { + return indexCurrencyFromPeer(peer); + } while(true) { try { @@ -120,6 +122,7 @@ public class CurrencyService extends AbstractService { * @return the created blockchain */ public Currency indexCurrencyFromPeer(Peer peer) { + BlockchainParameters parameters = blockchainRemoteService.getParameters(peer); BlockchainBlock firstBlock = blockchainRemoteService.getBlock(peer, 0l); BlockchainBlock currentBlock = blockchainRemoteService.getCurrentBlock(peer); diff --git a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/threadpool/LoggingScheduledThreadPoolExecutor.java b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/threadpool/LoggingScheduledThreadPoolExecutor.java index 4fb5efd9bc6cd49c9d6158b333d48d38bc79166b..5f2d4270bcc25d8bea88255a0bc0a5957304f61d 100644 --- a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/threadpool/LoggingScheduledThreadPoolExecutor.java +++ b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/threadpool/LoggingScheduledThreadPoolExecutor.java @@ -22,6 +22,7 @@ package org.duniter.elasticsearch.threadpool; * #L% */ +import org.duniter.core.exception.TechnicalException; import org.elasticsearch.common.logging.ESLogger; import java.util.concurrent.*; diff --git a/duniter4j-es-subscription/pom.xml b/duniter4j-es-subscription/pom.xml index 7d86bc1d0143039caea2f9749e8a9425fe2c81be..d96cfc71d29dba9aa075d3fcab2388420c227112 100644 --- a/duniter4j-es-subscription/pom.xml +++ b/duniter4j-es-subscription/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.duniter</groupId> <artifactId>duniter4j</artifactId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> </parent> <artifactId>duniter4j-es-subscription</artifactId> diff --git a/duniter4j-es-user/pom.xml b/duniter4j-es-user/pom.xml index aef75e177cb652afdb440d455a070095f643ee8f..8513639d13c9a89dcfcf5b875dc26850b0781a65 100644 --- a/duniter4j-es-user/pom.xml +++ b/duniter4j-es-user/pom.xml @@ -3,7 +3,7 @@ <parent> <artifactId>duniter4j</artifactId> <groupId>org.duniter</groupId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/pom.xml b/pom.xml index 28433699337641c6c0693ba17a1eb16383bfeff3..2831ed065f449e35ac1d3a50b091b0037678ba85 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ <groupId>org.duniter</groupId> <artifactId>duniter4j</artifactId> - <version>0.11.1-SNAPSHOT</version> + <version>0.11.2-SNAPSHOT</version> <packaging>pom</packaging> <name>Duniter4j : a Duniter Java Client API</name>