From b54a7edf71fe74b084fbfb35497169567c825d89 Mon Sep 17 00:00:00 2001 From: imalasong <2879499479@qq.com> Date: Mon, 21 Apr 2025 22:34:12 +0800 Subject: [PATCH] opt(common): GenesisBlock timestamp valid message error Signed-off-by: imalasong --- .../java/org/tron/common/args/GenesisBlock.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/org/tron/common/args/GenesisBlock.java b/common/src/main/java/org/tron/common/args/GenesisBlock.java index 1cc3394a0e1..fe6d30944d3 100644 --- a/common/src/main/java/org/tron/common/args/GenesisBlock.java +++ b/common/src/main/java/org/tron/common/args/GenesisBlock.java @@ -61,18 +61,17 @@ public void setAssets(final List assets) { */ public void setTimestamp(final String timestamp) { this.timestamp = timestamp; - if (this.timestamp == null) { this.timestamp = DEFAULT_TIMESTAMP; - } - - try { - long l = Long.parseLong(this.timestamp); - if (l < 0) { + } else { + try { + long l = Long.parseLong(this.timestamp); + if (l < 0) { + throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be greater than or equal to 0."); + } + } catch (NumberFormatException e) { throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be a Long type."); } - } catch (NumberFormatException e) { - throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be a Long type."); } }