diff --git a/pom.xml b/pom.xml
index 6dae45b38..8ab4c6ce4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
1.4.2
3.8.0
1.12.0
- 2.17.0
+ 2.18.0
1.27.1
3.17.0
1.2.2
@@ -28,7 +28,7 @@
1.2.1
2.7.4
76.1
- 4.12
+ 4.15
4.0.1
2.3.9
2.42
diff --git a/src/main/java/org/qortal/block/Block.java b/src/main/java/org/qortal/block/Block.java
index 086b3fc84..918a20ae9 100644
--- a/src/main/java/org/qortal/block/Block.java
+++ b/src/main/java/org/qortal/block/Block.java
@@ -145,6 +145,8 @@ public static class ExpandedAccount {
private final Account recipientAccount;
private final AccountData recipientAccountData;
+
+ final BlockChain blockChain = BlockChain.getInstance();
ExpandedAccount(Repository repository, RewardShareData rewardShareData) throws DataException {
this.rewardShareData = rewardShareData;
@@ -191,13 +193,12 @@ public AccountLevelShareBin getShareBin(int blockHeight) {
if (accountLevel <= 0)
return null; // level 0 isn't included in any share bins
- if (blockHeight >= BlockChain.getInstance().getFixBatchRewardHeight()) {
+ if (blockHeight >= blockChain.getFixBatchRewardHeight()) {
if (!this.isMinterMember)
return null; // not member of minter group isn't included in any share bins
}
// Select the correct set of share bins based on block height
- final BlockChain blockChain = BlockChain.getInstance();
final AccountLevelShareBin[] shareBinsByLevel = (blockHeight >= blockChain.getSharesByLevelV2Height()) ?
blockChain.getShareBinsByAccountLevelV2() : blockChain.getShareBinsByAccountLevelV1();
diff --git a/src/main/java/org/qortal/network/task/PeerConnectTask.java b/src/main/java/org/qortal/network/task/PeerConnectTask.java
index 7eec4e6b6..3ae1b6409 100644
--- a/src/main/java/org/qortal/network/task/PeerConnectTask.java
+++ b/src/main/java/org/qortal/network/task/PeerConnectTask.java
@@ -4,10 +4,15 @@
import org.apache.logging.log4j.Logger;
import org.qortal.network.Network;
import org.qortal.network.Peer;
+import org.qortal.utils.DaemonThreadFactory;
import org.qortal.utils.ExecuteProduceConsume.Task;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
public class PeerConnectTask implements Task {
private static final Logger LOGGER = LogManager.getLogger(PeerConnectTask.class);
+ private static final ExecutorService connectionExecutor = Executors.newCachedThreadPool(new DaemonThreadFactory(8));
private final Peer peer;
private final String name;
@@ -24,6 +29,24 @@ public String getName() {
@Override
public void perform() throws InterruptedException {
- Network.getInstance().connectPeer(peer);
+ // Submit connection task to a dedicated thread pool for non-blocking I/O
+ connectionExecutor.submit(() -> {
+ try {
+ connectPeerAsync(peer);
+ } catch (InterruptedException e) {
+ LOGGER.error("Connection attempt interrupted for peer {}", peer, e);
+ Thread.currentThread().interrupt(); // Reset interrupt flag
+ }
+ });
+ }
+
+ private void connectPeerAsync(Peer peer) throws InterruptedException {
+ // Perform peer connection in a separate thread to avoid blocking main task execution
+ try {
+ Network.getInstance().connectPeer(peer);
+ LOGGER.trace("Successfully connected to peer {}", peer);
+ } catch (Exception e) {
+ LOGGER.error("Error connecting to peer {}", peer, e);
+ }
}
}