|
10 | 10 | import org.springframework.beans.factory.annotation.Value;
|
11 | 11 | import org.springframework.stereotype.Component;
|
12 | 12 | import org.tron.common.utils.ByteArray;
|
| 13 | +import org.tron.common.utils.ByteUtil; |
13 | 14 | import org.tron.common.utils.Sha256Hash;
|
14 | 15 | import org.tron.core.capsule.BytesCapsule;
|
15 | 16 | import org.tron.core.config.Parameter;
|
@@ -119,6 +120,7 @@ private static class DynamicResourceProperties {
|
119 | 120 |
|
120 | 121 | private static final byte[] FORK_CONTROLLER = "FORK_CONTROLLER".getBytes();
|
121 | 122 | private static final String FORK_PREFIX = "FORK_VERSION_";
|
| 123 | + private static final byte[] SOLID_NUM_WITH_VERSION_5 = "SOLID_NUM_WITH_VERSION_5".getBytes(); |
122 | 124 |
|
123 | 125 | //This value is only allowed to be 0, 1, -1
|
124 | 126 | private static final byte[] REMOVE_THE_POWER_OF_THE_GR = "REMOVE_THE_POWER_OF_THE_GR".getBytes();
|
@@ -1411,6 +1413,18 @@ public byte[] statsByVersion(int version) {
|
1411 | 1413 | return revokingDB.getUnchecked(statsKey.getBytes());
|
1412 | 1414 | }
|
1413 | 1415 |
|
| 1416 | + public void setSolidNumWithVersion5(long blockNum) { |
| 1417 | + byte[] longBytes = ByteArray.fromLong(blockNum); |
| 1418 | + put(SOLID_NUM_WITH_VERSION_5, new BytesCapsule(longBytes)); |
| 1419 | + } |
| 1420 | + |
| 1421 | + public long getSolidNumWithVersion5() { |
| 1422 | + return Optional.ofNullable(getUnchecked(SOLID_NUM_WITH_VERSION_5)) |
| 1423 | + .map(BytesCapsule::getData) |
| 1424 | + .map(ByteArray::toLong) |
| 1425 | + .orElse(-1L); |
| 1426 | + } |
| 1427 | + |
1414 | 1428 | public boolean getForked() {
|
1415 | 1429 | byte[] value = revokingDB.getUnchecked(FORK_CONTROLLER);
|
1416 | 1430 | return value == null ? Boolean.FALSE : Boolean.valueOf(new String(value));
|
|
0 commit comments