diff --git a/README.md b/README.md index 51d7fce0..7fa40b5f 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,4 @@ To ensure the stability and reliability of this project, unit and mutation tests - FLYWAY_VALIDATE: whether to automatically call validate when performing a migration - KOIOS_BASE_URL_ENABLED: Set `true` to enable to use your Koios instance base URL, otherwise set `false` - KOIOS_BASE_URL: Koios instance base URL. +- KOIOS_AUTH_TOKEN: JWT Bearer Auth token generated via https://koios.rest Profile page diff --git a/docker-compose.yml b/docker-compose.yml index f303af00..0af8400e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,5 +27,6 @@ services: - FETCH_AND_SAVE_POOL_INFO_DATA_DELAY=${FETCH_AND_SAVE_POOL_INFO_DATA_DELAY} - KOIOS_BASE_URL_ENABLED=${KOIOS_BASE_URL_ENABLED} - KOIOS_BASE_URL=${KOIOS_BASE_URL} + - KOIOS_AUTH_TOKEN=${KOIOS_AUTH_TOKEN} ports: - ${SERVER_PORT}:${SERVER_PORT} diff --git a/pom.xml b/pom.xml index 1b0da61a..d4d29516 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ 17 1.18.26 1.18.24 - 1.17.2 + 1.18.1 0.1.0-SNAPSHOT 0.1.1-SNAPSHOT 0.1.12 diff --git a/src/main/java/org/cardanofoundation/explorer/rewards/config/KoiosClient.java b/src/main/java/org/cardanofoundation/explorer/rewards/config/KoiosClient.java index 97814d8a..7bdb75c1 100644 --- a/src/main/java/org/cardanofoundation/explorer/rewards/config/KoiosClient.java +++ b/src/main/java/org/cardanofoundation/explorer/rewards/config/KoiosClient.java @@ -1,5 +1,7 @@ package org.cardanofoundation.explorer.rewards.config; +import jakarta.annotation.PostConstruct; + import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @@ -26,31 +28,37 @@ public class KoiosClient { @Value("${application.koios-base-url}") private String baseUrl; + @Value("${application.koios-auth-token}") + private String authToken; + + private BackendService backendService; + public AccountService accountService() { - return this.getBackendService().getAccountService(); + return this.backendService.getAccountService(); } public NetworkService networkService() { - return this.getBackendService().getNetworkService(); + return this.backendService.getNetworkService(); } public PoolService poolService() { - return this.getBackendService().getPoolService(); + return this.backendService.getPoolService(); } public EpochService epochService() { - return this.getBackendService().getEpochService(); + return this.backendService.getEpochService(); } - private BackendService getBackendService() { + @PostConstruct + void setBackendService() { if (Boolean.TRUE.equals(baseUrlEnabled)) { - return BackendFactory.getCustomRPCService(baseUrl); + backendService = BackendFactory.getCustomRPCService(baseUrl, authToken); } else { - return switch (value) { - case NetworkConstants.MAINNET -> BackendFactory.getKoiosMainnetService(); - case NetworkConstants.PREPROD -> BackendFactory.getKoiosPreprodService(); - case NetworkConstants.PREVIEW -> BackendFactory.getKoiosPreviewService(); - case NetworkConstants.GUILDNET -> BackendFactory.getKoiosGuildService(); + backendService = switch (value) { + case NetworkConstants.MAINNET -> BackendFactory.getKoiosMainnetService(authToken); + case NetworkConstants.PREPROD -> BackendFactory.getKoiosPreprodService(authToken); + case NetworkConstants.PREVIEW -> BackendFactory.getKoiosPreviewService(authToken); + case NetworkConstants.GUILDNET -> BackendFactory.getKoiosGuildService(authToken); default -> throw new IllegalStateException("Unexpected value: " + value); }; } diff --git a/src/main/resources/config/application-dev.yaml b/src/main/resources/config/application-dev.yaml index 4f417d70..119fec31 100644 --- a/src/main/resources/config/application-dev.yaml +++ b/src/main/resources/config/application-dev.yaml @@ -68,6 +68,8 @@ application: network: ${NETWORK:mainnet} koios-base-url-enabled: ${KOIOS_BASE_URL_ENABLED:false} koios-base-url: ${KOIOS_BASE_URL:https://api.koios.rest/api/v0/} + koios-auth-token: ${KOIOS_AUTH_TOKEN} + reward: list-size-each-thread: ${REWARD_LIST_SIZE_EACH_THREAD:5} epoch-stake: diff --git a/src/main/resources/config/application-local.yaml b/src/main/resources/config/application-local.yaml index e7a02f7f..746de083 100644 --- a/src/main/resources/config/application-local.yaml +++ b/src/main/resources/config/application-local.yaml @@ -68,7 +68,9 @@ spring: application: network: ${NETWORK:mainnet} koios-base-url-enabled: ${KOIOS_BASE_URL_ENABLED:false} - koios-base-url: ${KOIOS_BASE_URL:https://api.koios.rest/api/v0/} + koios-base-url: ${KOIOS_BASE_URL:https://koios-api.pro.dandelion-mainnet.eu-west-1.metadata.dev.cf-deployments.org/rpc/} + koios-auth-token: ${KOIOS_AUTH_TOKEN:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyIjoic3Rha2UxdTg5eXZsNXB1OWhqenVkenF6amh3cHF2Y3Z3YTJ3dHNzNHljZG1seDM4Y2Foa2NwNWhzdmYiLCJleHAiOjE3Mzg2ODY5NjcsInRpZXIiOjEsInByb2pJRCI6ImNhcmRhbm9fZXhwbG9yZXJfcmV3YXJkIn0.vP9mbj4fDN3yz3c-kYloey9ssXbgqDcwVM3BSOJfk-g} + reward: list-size-each-thread: ${LIST_SIZE_EACH_THREAD:5} epoch-stake: diff --git a/src/main/resources/config/application-prod.yaml b/src/main/resources/config/application-prod.yaml index 99589d94..ece5d6a3 100644 --- a/src/main/resources/config/application-prod.yaml +++ b/src/main/resources/config/application-prod.yaml @@ -13,7 +13,7 @@ spring: hikari: pool-name: explorer-api-pool minimum-idle: 1 #minimum number of idle connections maintained by HikariCP in a connection pool - maximum-pool-size: 10 #maximum pool size + maximum-pool-size: 32 #maximum pool size idle-timeout: 300000 #maximum idle time for connection max-lifetime: 900000 #maximum lifetime in milliseconds of a connection in the pool after it is closed. connection-timeout: 50000 #maximum number of milliseconds that a client will wait for a connection @@ -63,15 +63,23 @@ spring: default-schema: ${spring.jpa.properties.hibernate.default_schema} schemas: ${spring.jpa.properties.hibernate.default_schema} validate-on-migrate: ${FLYWAY_VALIDATE:false} - + out-of-order: true application: network: ${NETWORK:mainnet} + koios-base-url-enabled: ${KOIOS_BASE_URL_ENABLED:false} + koios-base-url: ${KOIOS_BASE_URL:https://api.koios.rest/api/v0/} + koios-auth-token: ${KOIOS_AUTH_TOKEN} + reward: - list-size-each-thread: ${LIST_SIZE_EACH_THREAD:5} + list-size-each-thread: ${REWARD_LIST_SIZE_EACH_THREAD:5} epoch-stake: - list-size-each-thread: ${LIST_SIZE_EACH_THREAD:5} + list-size-each-thread: ${EPOCH_STAKE_LIST_SIZE_EACH_THREAD:5} pool-info: list-size-each-thread: ${POOL_INFO_LIST_SIZE_EACH_THREAD:500} job: enable: ${POOL_INFO_DATA_JOB_ENABLED:true} - fixed-delay: ${FETCH_AND_SAVE_POOL_INFO_DATA_DELAY:3600000} + fixed-delay: ${FETCH_AND_SAVE_POOL_INFO_DATA_DELAY:3600000} + +logging: + level: + rest.koios: ERROR \ No newline at end of file