Merge pull request #4398 from eviltofu/#4168_Add_documentation_to_describe_how_chains.zip_is_created_and_what_it_is_used_for
Added documentation and a target to Makefile to download, compress, and add the chains.zip file to the AlphaWallet project.pull/4338/head
commit
e582ba8f9c
@ -0,0 +1,22 @@ |
||||
The chains.json file is downloaded from https://chainid.network/chains.json. |
||||
|
||||
This file is then compressed using NSData.CompressionAlgorithm.lzma and stored raw without any headers. |
||||
|
||||
It is then renamed as chains.zip and must be added to the Rpc Network group of the project. |
||||
|
||||
A Makefile target has been added to automate this process. At the command line, type in: |
||||
|
||||
``` |
||||
make update_chains_file |
||||
``` |
||||
|
||||
and you should see the following response: |
||||
|
||||
```console |
||||
Deleting chains file in scripts folder. |
||||
Downloading chains file. |
||||
################################################################################################################# 100.0% |
||||
Compressing. |
||||
Moving compressed file into project. |
||||
Update completed. |
||||
``` |
@ -0,0 +1,24 @@ |
||||
#!/usr/bin/env swift |
||||
|
||||
import Foundation |
||||
|
||||
let selectedCompressionAlgorithm = NSData.CompressionAlgorithm.lzma |
||||
|
||||
func compressChainFile(inputFileName: String, outputFileName: String) throws { |
||||
let inputFileHandle = FileHandle(forReadingAtPath: inputFileName)! |
||||
let inputData = inputFileHandle.readDataToEndOfFile() as NSData |
||||
let outputData = try inputData.compressed(using: selectedCompressionAlgorithm) as Data |
||||
FileManager.default.createFile(atPath: outputFileName, contents: outputData, attributes: nil) |
||||
try inputFileHandle.close() |
||||
} |
||||
|
||||
do { |
||||
try compressChainFile(inputFileName: "scripts/chains.json", outputFileName: "scripts/chains.json.zip") |
||||
exit(0) |
||||
} catch { |
||||
print("An error occurred: \(error)") |
||||
exit(-1) |
||||
} |
||||
|
||||
|
||||
|
Loading…
Reference in new issue