Skip to content

Commit 8129f0e

Browse files
committed
rename some val and method
1 parent ca4f71d commit 8129f0e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/main/java/org/tron/common/utils/ForkController.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@
1717
import org.apache.commons.lang3.StringUtils;
1818
import org.tron.core.Wallet;
1919
import org.tron.core.capsule.BlockCapsule;
20-
import org.tron.core.config.Parameter;
2120
import org.tron.core.config.Parameter.ForkBlockVersionConsts;
2221
import org.tron.core.db.Manager;
2322

2423
@Slf4j
2524
@NoArgsConstructor(access = AccessLevel.PRIVATE)
2625
public class ForkController {
2726

27+
private static final byte VERSION_UPGRADE = (byte) 1;
28+
private static final byte HARD_FORK_EFFECTIVE = (byte) 2;
2829
private static final byte[] check;
2930
private static final byte[] check2;
3031
static {
3132
check = new byte[1024];
32-
Arrays.fill(check, (byte) 1);
33+
Arrays.fill(check, VERSION_UPGRADE);
3334
check2 = new byte[1024];
34-
Arrays.fill(check2, (byte) 2);
35+
Arrays.fill(check2, HARD_FORK_EFFECTIVE);
3536
}
3637

3738
@Getter
@@ -45,7 +46,7 @@ public void init(Manager manager) {
4546
}
4647

4748
public synchronized boolean pass(int version) {
48-
if (!check(version)) {
49+
if (!checkEnergy(version)) {
4950
return false;
5051
}
5152

@@ -67,7 +68,10 @@ public synchronized boolean pass(int version) {
6768
return pass;
6869
}
6970

70-
private boolean check(int version) {
71+
// when block.version = 5,
72+
// it make block use new energy to handle transaction when block number >= 4727890L.
73+
// version !=5, skip this.
74+
private boolean checkEnergy(int version) {
7175
if (version != ForkBlockVersionConsts.ENERGY_LIMIT) {
7276
return true;
7377
}
@@ -120,7 +124,7 @@ public synchronized void update(BlockCapsule blockCapsule) {
120124
stats = new byte[witnesses.size()];
121125
}
122126

123-
stats[slot] = (byte) 1;
127+
stats[slot] = VERSION_UPGRADE;
124128
manager.getDynamicPropertiesStore().statsByVersion(version, stats);
125129
logger.info(
126130
"*******update hard fork:{}, witness size:{}, solt:{}, witness:{}, version:{}",
@@ -146,7 +150,7 @@ public synchronized void updateWhenMaintenance(BlockCapsule blockCapsule) {
146150
}
147151

148152
if (check(stats)) {
149-
Arrays.fill(stats, (byte) 2);
153+
Arrays.fill(stats, HARD_FORK_EFFECTIVE);
150154
manager.getDynamicPropertiesStore().statsByVersion(version, stats);
151155
logger.info("*******hard fork is effective in the maintenance, version is {}", version);
152156
}

0 commit comments

Comments
 (0)