Skip to content

Commit 1106a91

Browse files
committed
Process blocks only after a while.
1 parent a5d05e5 commit 1106a91

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/java/burst/pool/miners/Miner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void recalculateCapacity(long currentBlockHeight) {
3333
// Calculate hitSum
3434
BigInteger hitSumShared = BigInteger.ZERO;
3535
BigInteger hitSum = BigInteger.ZERO;
36-
AtomicInteger deadlineCount = new AtomicInteger(store.getDeadlineCount());
36+
int deadlineCount = store.getDeadlineCount();
3737
List<Deadline> deadlines = store.getDeadlines();
3838
for(Deadline deadline : deadlines) {
3939
if (currentBlockHeight - deadline.getHeight() >= propertyService.getInt(Props.nAvg)) {
@@ -56,7 +56,7 @@ public void recalculateCapacity(long currentBlockHeight) {
5656
}
5757
// Calculate estimated capacity
5858
try {
59-
store.setSharedCapacity(minerMaths.estimatedEffectivePlotSize(deadlines.size(), deadlineCount.get(), hitSumShared));
59+
store.setSharedCapacity(minerMaths.estimatedEffectivePlotSize(deadlines.size(), deadlineCount, hitSumShared));
6060
store.setTotalCapacity(minerMaths.estimatedTotalPlotSize(deadlines.size(), hitSum));
6161
} catch (ArithmeticException ignored) {
6262
}

src/main/java/burst/pool/pool/Pool.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.slf4j.LoggerFactory;
3232

3333
import java.math.BigInteger;
34+
import java.time.Duration;
3435
import java.time.Instant;
3536
import java.util.*;
3637
import java.util.concurrent.Semaphore;
@@ -125,6 +126,15 @@ private Completable processNextBlock() {
125126
if (miningInfo.get() == null || processBlockSemaphore.availablePermits() == 0 || miningInfo.get().getHeight() - 1 <= storageService.getLastProcessedBlock() + propertyService.getInt(Props.processLag)) {
126127
return;
127128
}
129+
130+
// Leave the process blocks only a minute after starting a new round
131+
// TODO: add a configuration for this
132+
Duration roundDuration = Duration.between(roundStartTime.get(), Instant.now());
133+
if(roundDuration.toMillis() < 60000) {
134+
return;
135+
}
136+
137+
logger.info("Started processing block {}", storageService.getLastProcessedBlock() + 1);
128138

129139
try {
130140
processBlockSemaphore.acquire();
@@ -261,6 +271,8 @@ private void onProcessedBlock(StorageService transactionalStorageService, boolea
261271
if (actuallyProcessed) {
262272
minerTracker.payoutIfNeeded(storageService, transactionFee.get());
263273
}
274+
275+
logger.info("Finished processing block {}", storageService.getLastProcessedBlock());
264276
}
265277

266278
private void resetRound(MiningInfo newMiningInfo) {

0 commit comments

Comments
 (0)