Skip to content

Commit 7018d54

Browse files
authored
Merge pull request #413 from yungwine/testnet-dump
add testnet dump downloading
2 parents 46bd164 + eee0e9d commit 7018d54

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

mytoninstaller/settings.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,25 @@ def FirstNodeSettings(local):
9191
StartValidator(local)
9292
#end define
9393

94+
def is_testnet(local):
95+
testnet_zero_state_root_hash = "gj+B8wb/AmlPk1z1AhVI484rhrUpgSr2oSFIh56VoSg="
96+
with open(local.buffer.global_config_path) as f:
97+
config = json.load(f)
98+
if config['validator']['zero_state']['root_hash'] == testnet_zero_state_root_hash:
99+
return True
100+
return False
101+
94102
def DownloadDump(local):
95103
dump = local.buffer.dump
96-
if dump == False:
104+
if dump is False:
97105
return
98106
#end if
99107

100108
local.add_log("start DownloadDump function", "debug")
101-
url = "https://dump.ton.org"
102-
dumpSize = requests.get(url + "/dumps/latest.tar.size.archive.txt").text
109+
url = "https://dump.ton.org/dumps/latest"
110+
if is_testnet(local):
111+
url += '_testnet'
112+
dumpSize = requests.get(url + ".tar.size.archive.txt").text
103113
print("dumpSize:", dumpSize)
104114
needSpace = int(dumpSize) * 3
105115
diskSpace = psutil.disk_usage("/var")
@@ -113,7 +123,7 @@ def DownloadDump(local):
113123

114124
# download dump using aria2c to a temporary file
115125
temp_file = "/tmp/latest.tar.lz"
116-
cmd = f"aria2c -x 8 -s 8 -c {url}/dumps/latest.tar.lz -d / -o {temp_file}"
126+
cmd = f"aria2c -x 8 -s 8 -c {url}.tar.lz -d / -o {temp_file}"
117127
os.system(cmd)
118128

119129
# process the downloaded file

0 commit comments

Comments
 (0)