Skip to content

Commit b54a7ed

Browse files
committed
opt(common): GenesisBlock timestamp valid message error
Signed-off-by: imalasong <[email protected]>
1 parent 2cc57bd commit b54a7ed

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

common/src/main/java/org/tron/common/args/GenesisBlock.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,17 @@ public void setAssets(final List<Account> assets) {
6161
*/
6262
public void setTimestamp(final String timestamp) {
6363
this.timestamp = timestamp;
64-
6564
if (this.timestamp == null) {
6665
this.timestamp = DEFAULT_TIMESTAMP;
67-
}
68-
69-
try {
70-
long l = Long.parseLong(this.timestamp);
71-
if (l < 0) {
66+
} else {
67+
try {
68+
long l = Long.parseLong(this.timestamp);
69+
if (l < 0) {
70+
throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be greater than or equal to 0.");
71+
}
72+
} catch (NumberFormatException e) {
7273
throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be a Long type.");
7374
}
74-
} catch (NumberFormatException e) {
75-
throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be a Long type.");
7675
}
7776
}
7877

0 commit comments

Comments
 (0)