Skip to content

Commit 1919d8a

Browse files
committed
fix block size overflow
1 parent acf379e commit 1919d8a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,12 +923,10 @@ public synchronized BlockCapsule generateBlock(
923923
throw new IllegalArgumentException("generate block timestamp is invalid.");
924924
}
925925

926-
long currentTrxSize = 0;
927926
long postponedTrxCount = 0;
928927

929928
final BlockCapsule blockCapsule =
930929
new BlockCapsule(number + 1, preHash, when, witnessCapsule.getAddress());
931-
currentTrxSize = blockCapsule.getInstance().getSerializedSize();
932930
dialog.reset();
933931
dialog.setValue(revokingStore.buildDialog());
934932
Iterator iterator = pendingTransactions.iterator();
@@ -939,9 +937,8 @@ public synchronized BlockCapsule generateBlock(
939937
logger.debug("Processing transaction time exceeds the 50% producing time。");
940938
break;
941939
}
942-
currentTrxSize += trx.getSerializedSize() + 2;
943940
// check the block size
944-
if (currentTrxSize > ChainConstant.BLOCK_SIZE) {
941+
if ((blockCapsule.getInstance().getSerializedSize() + trx.getSerializedSize() + 3) > ChainConstant.BLOCK_SIZE) {
945942
postponedTrxCount++;
946943
continue;
947944
}

0 commit comments

Comments
 (0)