Support downloading SSZ genesis files with curl

This commit is contained in:
Zahary Karadjov 2019-09-27 18:59:28 +03:00
parent 5152c42c8e
commit b56c96a4fd
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 4 additions and 2 deletions

View File

@ -59,11 +59,13 @@ template `//`(url, fragment: string): string =
url & "/" & fragment
proc downloadFile(url: string): Future[string] {.async.} =
let cmd = "curl --fail " & url
# TODO We need a proper HTTP client able to perform HTTPS downloads
let tempFile = getTempDir() / "nimbus.download"
let cmd = "curl --fail -o " & quoteShell(tempFile) & " " & url
let (fileContents, errorCode) = execCmdEx(cmd, options = {poUsePath})
if errorCode != 0:
raise newException(IOError, "Failed external command: '" & cmd & "', exit code: " & $errorCode & ", output: '" & fileContents & "'")
return fileContents
return readFile(tempFile)
proc updateTestnetMetadata(conf: BeaconNodeConf): Future[NetworkMetadata] {.async.} =
let metadataUrl = testnetsBaseUrl // $conf.network // networkMetadataFile