Skip to content

Commit

Permalink
init latestSaveBlockTime in init method
Browse files Browse the repository at this point in the history
  • Loading branch information
317787106 committed Jul 9, 2024
1 parent 5bf9ea3 commit 15b3abc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion chainbase/src/main/java/org/tron/core/ChainBaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public class ChainBaseManager {

@Getter
@Setter
private long latestSaveBlockTime = System.currentTimeMillis();
private long latestSaveBlockTime;

// for test only
public List<ByteString> getWitnesses() {
Expand Down Expand Up @@ -385,6 +385,7 @@ private void init() {
this.lowestBlockNum = this.blockIndexStore.getLimitNumber(1, 1).stream()
.map(BlockId::getNum).findFirst().orElse(0L);
this.nodeType = getLowestBlockNum() > 1 ? NodeType.LITE : NodeType.FULL;
this.latestSaveBlockTime = System.currentTimeMillis();
}

public void shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public class PeerConnection {

private final ResilienceConfig resilienceConfig = Args.getInstance().getResilienceConfig();

private final boolean testStopInv = Args.getInstance().getResilienceConfig().isEnabled()
&& Args.getInstance().getResilienceConfig().isTestStopInv();

@Getter
private final MaliciousFeature maliciousFeature = new MaliciousFeature();

Expand Down Expand Up @@ -348,15 +351,13 @@ private long getLatestTime() {
public class MaliciousFeature {

@Setter
private long advStartTime = System.currentTimeMillis();
private long advStartTime;
@Setter
private long stopBlockInvStartTime = -1;
@Setter
private long stopBlockInvEndTime = -1;
@Setter
private long lastRecBlockInvTime = -1;
//if testStopInv=true, we use feature 4, else use feature 3. We an only use one of them.
private final boolean testStopInv;

//four features
private long badSyncBlockChainTime = -1; //feature 1
Expand All @@ -365,7 +366,7 @@ public class MaliciousFeature {
private long zombieBeginTime2 = -1; //feature 4

public MaliciousFeature() {
testStopInv = Args.getInstance().getResilienceConfig().isTestStopInv();
advStartTime = System.currentTimeMillis();
}

//it can only be set from -1 to positive
Expand Down Expand Up @@ -426,6 +427,7 @@ public long getEarliestTime() {
}

public boolean isMalicious() {
//if testStopInv=true, we use feature 4, else use feature 3. We an only use one of them.
boolean isMalicious = testStopInv ? (maliciousFeature.zombieBeginTime2 > 0)
: (maliciousFeature.zombieBeginTime > 0);
return maliciousFeature.badSyncBlockChainTime > 0
Expand Down

0 comments on commit 15b3abc

Please sign in to comment.