Skip to content

Commit 5c257a1

Browse files
committed
optimize log and code
1 parent 88a5bb5 commit 5c257a1

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
lines changed

src/main/java/org/tron/core/net/node/NodeDelegateImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ public synchronized LinkedList<Sha256Hash> handleBlock(BlockCapsule block, boole
102102

103103
@Override
104104
public void handleTransaction(TransactionCapsule trx) throws BadTransactionException {
105-
logger.info("handle transaction");
106-
105+
logger.debug("handle transaction");
107106
if (dbManager.getTransactionIdCache().getIfPresent(trx.getTransactionId()) != null) {
108107
logger.warn("This transaction has been processed");
109108
return;

src/main/java/org/tron/core/net/node/NodeImpl.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,13 @@ public class NodeImpl extends PeerConnectionDelegate implements Node {
9090
.maximumSize(10).expireAfterWrite(60, TimeUnit.SECONDS)
9191
.recordStats().build();
9292

93-
// private Cache<Long, Long> fetchWaterLine = CacheBuilder.newBuilder()
94-
// .expireAfterWrite(BLOCK_PRODUCED_INTERVAL / 1000 * MSG_CACHE_DURATION_IN_BLOCKS, TimeUnit.SECONDS)
95-
// .recordStats().build();
96-
9793
private SlidingWindowCounter fetchWaterLine =
98-
new SlidingWindowCounter(BLOCK_PRODUCED_INTERVAL / 100 * MSG_CACHE_DURATION_IN_BLOCKS);
99-
100-
94+
new SlidingWindowCounter(BLOCK_PRODUCED_INTERVAL * MSG_CACHE_DURATION_IN_BLOCKS / 100);
10195

10296
private int maxTrxsSize = 1_000_000;
10397

10498
private int maxTrxsCnt = 100;
10599

106-
107100
@Getter
108101
class PriorItem implements java.lang.Comparable<PriorItem> {
109102

@@ -735,25 +728,10 @@ private void onHandleInventoryMessage(PeerConnection peer, InventoryMessage msg)
735728
}
736729

737730
private boolean isFlooded() {
738-
// try {
739-
// long value = fetchWaterLine.get(Time.getCurrentMillis() / 1000, () -> 0L);
740-
// fetchWaterLine.put(Time.getCurrentMillis() / 1000, value);
741-
// } catch (ExecutionException e) {
742-
// e.printStackTrace();
743-
// }
744731
return fetchWaterLine.totalCount()
745732
> BLOCK_PRODUCED_INTERVAL * NET_MAX_TRX_PER_SECOND * MSG_CACHE_DURATION_IN_BLOCKS / 1000;
746733
}
747734

748-
// private void addWaterLine() {
749-
// try {
750-
// long value = fetchWaterLine.get(Time.getCurrentMillis() / 1000, () -> 0L);
751-
// fetchWaterLine.put(Time.getCurrentMillis() / 1000, ++value);
752-
// } catch (ExecutionException e) {
753-
// e.printStackTrace();
754-
// }
755-
// }
756-
757735
@Override
758736
public void syncFrom(Sha256Hash myHeadBlockHash) {
759737
try {
@@ -767,7 +745,6 @@ public void syncFrom(Sha256Hash myHeadBlockHash) {
767745
logger.info("wait end");
768746
}
769747

770-
771748
private void onHandleBlockMessage(PeerConnection peer, BlockMessage blkMsg) {
772749
Map<Item, Long> advObjWeRequested = peer.getAdvObjWeRequested();
773750
Map<BlockId, Long> syncBlockRequested = peer.getSyncBlockRequested();

src/main/java/org/tron/core/net/peer/PeerConnection.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.tron.core.net.peer;
22

3-
import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL;
43
import static org.tron.core.config.Parameter.NetConstants.MAX_INVENTORY_SIZE_IN_MINUTES;
54
import static org.tron.core.config.Parameter.NetConstants.NET_MAX_TRX_PER_SECOND;
65

@@ -169,12 +168,7 @@ private void removeIterator(Iterator<Entry<Sha256Hash, Long>> iterator, long old
169168
}
170169

171170
public boolean isAdvInvFull() {
172-
if (advObjSpreadToUs.size() > MAX_INVENTORY_SIZE_IN_MINUTES * 60 * NET_MAX_TRX_PER_SECOND
173-
+ (MAX_INVENTORY_SIZE_IN_MINUTES + 1) * 60 / BLOCK_PRODUCED_INTERVAL) {
174-
logger.info("adv is full!!!, advObjSpreadToUs size:" + advObjSpreadToUs.size());
175-
return true;
176-
}
177-
return false;
171+
return advObjSpreadToUs.size() > MAX_INVENTORY_SIZE_IN_MINUTES * 60 * NET_MAX_TRX_PER_SECOND;
178172
}
179173

180174
public boolean isBanned() {

0 commit comments

Comments
 (0)