Skip to content

Commit 5312d41

Browse files
authored
Merge pull request #6295 from imalasong/pr/250421
opt(common): GenesisBlock timestamp valid message error
2 parents 52b1723 + b54a7ed commit 5312d41

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

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)