Skip to content

Commit c42bdcd

Browse files
Merge pull request #910 from tronprotocol/add_time_out
feat:add time out when generate Block.
2 parents 446eaa7 + 8d36ad4 commit c42bdcd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ public BlockId getBlockIdByNum(final long num) throws ItemNotFoundException {
905905
public BlockCapsule getBlockByNum(final long num) throws ItemNotFoundException, BadItemException {
906906
return getBlockById(getBlockIdByNum(num));
907907
}
908+
908909
/**
909910
* Generate a block.
910911
*/
@@ -933,13 +934,14 @@ public synchronized BlockCapsule generateBlock(
933934
Iterator iterator = pendingTransactions.iterator();
934935
while (iterator.hasNext()) {
935936
TransactionCapsule trx = (TransactionCapsule) iterator.next();
936-
if (DateTime.now().getMillis() - when > ChainConstant.BLOCK_PRODUCED_INTERVAL * 0.5) {
937+
if (DateTime.now().getMillis() - when
938+
> ChainConstant.BLOCK_PRODUCED_INTERVAL * 0.5 * ChainConstant.BLOCK_PRODUCED_TIME_OUT) {
937939
logger.debug("Processing transaction time exceeds the 50% producing time。");
938940
break;
939941
}
940942
currentTrxSize += trx.getSerializedSize() + 2;
941943
// check the block size
942-
if (currentTrxSize > ChainConstant.BLOCK_SIZE) {
944+
if (currentTrxSize > ChainConstant.BLOCK_SIZE) {
943945
postponedTrxCount++;
944946
continue;
945947
}

0 commit comments

Comments
 (0)