Skip to content

Commit 49b41e9

Browse files
authored
Merge pull request #638 from tronprotocol/fix_estimate_size
use trx.getSerializedSize for estimate block size
2 parents 0c1d89e + 344b7c8 commit 49b41e9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/java/org/tron/core/capsule/TransactionCapsule.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ public byte[] getData() {
360360
return this.transaction.toByteArray();
361361
}
362362

363+
public long getSerializedSize() {
364+
return this.transaction.getSerializedSize();
365+
}
366+
363367
@Override
364368
public Transaction getInstance() {
365369
return this.transaction;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ public synchronized BlockCapsule generateBlock(
861861
Iterator iterator = pendingTransactions.iterator();
862862
while (iterator.hasNext()) {
863863
TransactionCapsule trx = (TransactionCapsule) iterator.next();
864-
currentTrxSize += RamUsageEstimator.sizeOf(trx);
864+
currentTrxSize += trx.getSerializedSize();
865865
// judge block size
866866
if (currentTrxSize > ChainConstant.TRXS_SIZE) {
867867
postponedTrxCount++;

0 commit comments

Comments
 (0)