Skip to content

Commit 39feab6

Browse files
committed
perf(db): optimize generate block logic
1 parent 85f7278 commit 39feab6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

framework/src/main/java/org/tron/core/db/Manager.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,12 @@ public synchronized BlockCapsule generateBlock(Miner miner, long blockTime, long
14281428
MetricLabels.Gauge.QUEUE_REPUSH);
14291429
}
14301430

1431+
if (fromPending) {
1432+
pendingTransactions.poll();
1433+
Metrics.gaugeInc(MetricKeys.Gauge.MANAGER_QUEUE, -1,
1434+
MetricLabels.Gauge.QUEUE_PENDING);
1435+
}
1436+
14311437
if (trx == null) {
14321438
// transaction may be removed by rePushLoop.
14331439
logger.warn("Trx is null,fromPending:{},pending:{},repush:{}.",
@@ -1474,11 +1480,6 @@ public synchronized BlockCapsule generateBlock(Miner miner, long blockTime, long
14741480
if (Objects.nonNull(result)) {
14751481
transactionRetCapsule.addTransactionInfo(result);
14761482
}
1477-
if (fromPending) {
1478-
pendingTransactions.poll();
1479-
Metrics.gaugeInc(MetricKeys.Gauge.MANAGER_QUEUE, -1,
1480-
MetricLabels.Gauge.QUEUE_PENDING);
1481-
}
14821483
} catch (Exception e) {
14831484
logger.error("Process trx {} failed when generating block: {}", trx.getTransactionId(),
14841485
e.getMessage());

0 commit comments

Comments
 (0)