Skip to content

Commit 2d3aa37

Browse files
authored
Merge pull request #942 from tronprotocol/optimizeLog
optimize SR log
2 parents b21ca8e + c8842be commit 2d3aa37

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

src/main/java/org/tron/core/services/WitnessService.java

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.tron.core.services;
22

3+
import static org.tron.core.witness.BlockProductionCondition.NOT_MY_TURN;
4+
35
import com.google.common.collect.Maps;
46
import com.google.protobuf.ByteString;
57
import java.util.Map;
@@ -101,41 +103,10 @@ private void blockProductionLoop() throws InterruptedException {
101103
return;
102104
}
103105

104-
switch (result) {
105-
case PRODUCED:
106-
logger.debug("Produced");
107-
break;
108-
case NOT_SYNCED:
109-
logger.info("Not sync");
110-
break;
111-
case UNELECTED:
112-
logger.debug("Unelected");
113-
break;
114-
case NOT_MY_TURN:
115-
logger.debug("It's not my turn");
116-
break;
117-
case NOT_TIME_YET:
118-
logger.info("Not time yet");
119-
break;
120-
case NO_PRIVATE_KEY:
121-
logger.info("No pri key");
122-
break;
123-
case LOW_PARTICIPATION:
124-
logger.info("Low part");
125-
break;
126-
case LAG:
127-
logger.info("Lag");
128-
break;
129-
case CONSECUTIVE:
130-
logger.info("Consecutive");
131-
break;
132-
case TIME_OUT:
133-
logger.debug("Time out");
134-
case EXCEPTION_PRODUCING_BLOCK:
135-
logger.info("Exception");
136-
break;
137-
default:
138-
break;
106+
if (result.ordinal() <= NOT_MY_TURN.ordinal()) {
107+
logger.debug(result.toString());
108+
} else {
109+
logger.info(result.toString());
139110
}
140111
}
141112

@@ -209,7 +180,7 @@ private BlockProductionCondition tryProduceBlock() throws InterruptedException {
209180
logger.info("It's not my turn, ScheduledWitness[{}],slot[{}],abSlot[{}],",
210181
ByteArray.toHexString(scheduledWitness.toByteArray()), slot,
211182
controller.getAbSlotAtTime(now));
212-
return BlockProductionCondition.NOT_MY_TURN;
183+
return NOT_MY_TURN;
213184
}
214185

215186
long scheduledTime = controller.getSlotTime(slot);

src/main/java/org/tron/core/witness/BlockProductionCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
public enum BlockProductionCondition {
44
PRODUCED, // Successfully generated block
5-
NOT_SYNCED,
65
UNELECTED,
76
NOT_MY_TURN, // It isn't my turn
7+
NOT_SYNCED,
88
NOT_TIME_YET, // Not yet arrived
99
NO_PRIVATE_KEY,
1010
LOW_PARTICIPATION,

0 commit comments

Comments
 (0)