Update Run Codex and other refactoring (#14)

This commit is contained in:
Slava 2024-09-27 22:31:39 +03:00 committed by GitHub
parent a92512370d
commit 38d58c1958
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,164 +1,206 @@
# Quick start # Quick start
To join the Codex testnet we would need to perform the following steps: To run Codex through this guide we would need to perform the following steps:
- [Review the disclaimer](/codex/disclaimer) - [Review the disclaimer](/codex/disclaimer)
- [Get Codex binary](#get-codex-binary) - [Get Codex binary](#get-codex-binary)
- [Run Codex](#run-codex) - [Run Codex](#run-codex)
- [Interact with Codex](#interact-with-codex) - [Interact with Codex](#interact-with-codex)
### Get Codex binary ## Get Codex binary
For quick start we will use precompiled binaries from [GitHub release page](https://github.com/codex-storage/nim-codex/releases). If you prefer to compile from the sources, please check [Build Codex](/learn/build). For quick start we will use precompiled binaries from [GitHub release page](https://github.com/codex-storage/nim-codex/releases). If you prefer to compile from the sources, please check [Build Codex](/learn/build).
Please follow the steps for your OS from the list: Please follow the steps for your OS from the list:
- [Linux/macOS](#linux-macos) - [Linux/macOS](#linux-macos)
- [Windows](#windows) - [Windows](#windows)
#### Linux/macOS ### Linux/macOS
1. Download binary and checksum for your platform/architecture 1. Download binary and checksum for your platform/architecture
```shell ```shell
version=v0.1.4 version=v0.1.4
platform=$(echo `uname -s` | awk '{print tolower($0)}') platform=$(echo `uname -s` | awk '{print tolower($0)}')
architecture=$([[ `uname -m` == 'x86_64' ]] && echo amd64 || echo arm64) architecture=$([[ `uname -m` == 'x86_64' ]] && echo amd64 || echo arm64)
# Binary # Binary
curl -LO https://github.com/codex-storage/nim-codex/releases/download/${version}/codex-${version}-${platform}-${architecture}.tar.gz curl -LO https://github.com/codex-storage/nim-codex/releases/download/${version}/codex-${version}-${platform}-${architecture}.tar.gz
# Checksum # Checksum
curl -LO https://github.com/codex-storage/nim-codex/releases/download/${version}/codex-${version}-${platform}-${architecture}.tar.gz.sha256 curl -LO https://github.com/codex-storage/nim-codex/releases/download/${version}/codex-${version}-${platform}-${architecture}.tar.gz.sha256
```
2. Verify checksum
**Linux**
```shell
sha256sum -c codex-${version}-${platform}-${architecture}.tar.gz.sha256
```
**macOS**
```shell
shasum -a 256 -c codex-${version}-${platform}-${architecture}.tar.gz.sha256
```
Make sure you get `OK` in the result
```
codex-v0.1.4-linux-amd64.tar.gz: OK
```
3. Extract binary
```shell
tar -zxvf codex-${version}-${platform}-${architecture}.tar.gz
```
4. Copy binary to the appropriate folder
```shell
sudo install codex-${version}-${platform}-${architecture} /usr/local/bin/codex
```
5. Install dependencies
```shell
# Debian-based Linux
sudo apt update && sudo apt install libgomp1
```
6. Check the result
```shell
codex --version
```
```shell
Codex version: v0.1.4
Codex revision: 484124d
Nim Compiler Version 1.6.14 [Linux: amd64]
```
7. Cleanup
```shell
rm -f \
codex-${version}-${platform}-${architecture} \
codex-${version}-${platform}-${architecture}.tar.gz \
codex-${version}-${platform}-${architecture}.tar.gz.sha256
```
### Windows
1. Download binary and checksum for your platform/architecture
::: warning
For Windows, only amd64 architecture is supported now.
:::
```batch
set version=v0.1.4
set platform=windows
if %PROCESSOR_ARCHITECTURE%==AMD64 (set architecture=amd64) else (set architecture=arm64)
:: Binary
curl -LO https://github.com/codex-storage/nim-codex/releases/download/%version%/codex-%version%-%platform%-%architecture%-libs.zip
:: Checksum
curl -LO https://github.com/codex-storage/nim-codex/releases/download/%version%/codex-%version%-%platform%-%architecture%-libs.zip.sha256
```
2. Verify checksum
```batch
for /f "delims=" %a in ('certUtil -hashfile codex-%version%-%platform%-%architecture%-libs.zip SHA256 ^| findstr -vrc:"[^0123-9aAb-Cd-EfF ]"') do @set ACTUAL_HASH=%a
for /f "tokens=1" %a in (codex-%version%-%platform%-%architecture%-libs.zip.sha256) do set EXPECTED_HASH=%a
if %ACTUAL_HASH% == %EXPECTED_HASH% (echo. && echo codex-%version%-%platform%-%architecture%-libs.zip: OK) else (echo. && echo codex-%version%-%platform%-%architecture%-libs.zip: FAILED)
``` ```
2. Verify checksum Make sure you get `OK` in the result
```
codex-v0.1.4-windows-amd64-libs.zip: OK
```
**Linux** 3. Extract binary and libraries
```shell ```batch
sha256sum -c codex-${version}-${platform}-${architecture}.tar.gz.sha256 if not exist %LOCALAPPDATA%\Codex mkdir %LOCALAPPDATA%\Codex
``` tar -xvf codex-%version%-%platform%-%architecture%-libs.zip -C %LOCALAPPDATA%\Codex
**macOS** 4. Rename binary and update user `path` variable
```shell ```batch
shasum -a 256 -c codex-${version}-${platform}-${architecture}.tar.gz.sha256 :: Rename binary
``` move /Y %LOCALAPPDATA%\Codex\codex-%version%-%platform%-%architecture%.exe %LOCALAPPDATA%\Codex\codex.exe
Make sure you get `OK` in the result :: Add folder to the path permanently
``` setx PATH %PATH%%LOCALAPPDATA%\Codex;
codex-v0.1.4-linux-amd64.tar.gz: OK
```
3. Extract binary :: Add folder to the path for the current session
```shell PATH %PATH%%LOCALAPPDATA%\Codex;
tar -zxvf codex-${version}-${platform}-${architecture}.tar.gz ```
```
4. Copy binary to the appropriate folder 4. Check the result
```shell ```shell
sudo install codex-${version}-${platform}-${architecture} /usr/local/bin/codex codex --version
``` ```
```shell
Codex version: v0.1.4
Codex revision: 484124d
Nim Compiler Version 1.6.14 [Windows: amd64]
Compiled at 2024-06-27
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 38640664088251bbc88917b4bacfd86ec53014b8
active boot switches: -d:release
```
5. Install dependencies 5. Cleanup
```shell ```batch
# Debian-based Linux del codex-%version%-%platform%-%architecture%-libs.zip ^
sudo apt update && sudo apt install libgomp1 codex-%version%-%platform%-%architecture%-libs.zip.sha256
``` ```
6. Check the result ## Run Codex
```shell
codex --version
```
```shell
Codex version: v0.1.4
Codex revision: 484124d
Nim Compiler Version 1.6.14 [Linux: amd64]
```
7. Cleanup We may [run Codex in different modes](/learn/run#run), and for a quick start we will run [Codex node](/learn/run#codex-node), to be able to share files in the network.
```shell
rm -f \
codex-${version}-${platform}-${architecture} \
codex-${version}-${platform}-${architecture}.tar.gz \
codex-${version}-${platform}-${architecture}.tar.gz.sha256
```
#### Windows 1. Run Codex
1. Download binary and checksum for your platform/architecture **Linux/macOS**
::: warning ```shell
For Windows, only amd64 architecture is supported now. codex \
::: --data-dir=datadir \
```batch --disc-port=8090 \
set version=v0.1.4 --listen-addrs=/ip4/0.0.0.0/tcp/8070 \
set platform=windows --nat=`curl -s https://ip.codex.storage` \
if %PROCESSOR_ARCHITECTURE%==AMD64 (set architecture=amd64) else (set architecture=arm64) --api-cors-origin="*" \
--bootstrap-node=spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P
```
:: Binary **Windows**
curl -LO https://github.com/codex-storage/nim-codex/releases/download/%version%/codex-%version%-%platform%-%architecture%-libs.zip ```batch
:: Get Public IP
for /f "delims=" %a in ('curl -s https://ip.codex.storage') do @set nat=%a
:: Checksum :: Run
curl -LO https://github.com/codex-storage/nim-codex/releases/download/%version%/codex-%version%-%platform%-%architecture%-libs.zip.sha256 codex ^
``` --data-dir=datadir ^
--disc-port=8090 ^
--listen-addrs=/ip4/0.0.0.0/tcp/8070 ^
--nat=%nat% ^
--api-cors-origin="*" ^
--bootstrap-node=spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P
```
2. Verify checksum ::: tip
```batch In the example above we use [Codex Testnet](/networks/testnet#bootstrap-nodes) bootstrap nodes and thus we join Testnet. If you would like to join a different network, please use [appropriate value](/networks/networks).
for /f "delims=" %a in ('certUtil -hashfile codex-%version%-%platform%-%architecture%-libs.zip SHA256 ^| findstr -vrc:"[^0123-9aAb-Cd-EfF ]"') do @set ACTUAL_HASH=%a :::
for /f "tokens=1" %a in (codex-%version%-%platform%-%architecture%-libs.zip.sha256) do set EXPECTED_HASH=%a
if %ACTUAL_HASH% == %EXPECTED_HASH% (echo. && echo codex-%version%-%platform%-%architecture%-libs.zip: OK) else (echo. && echo codex-%version%-%platform%-%architecture%-libs.zip: FAILED)
```
Make sure you get `OK` in the result 2. Configure port-forwarding for the TCP/UDP ports on your Internet router
``` | Protocol | Service | Port |
codex-v0.1.4-windows-amd64-libs.zip: OK | -------- | --------- | ------ |
``` | UDP | Discovery | `8090` |
| TCP | Transport | `8070` |
3. Extract binary and libraries If you would like to purchase or sell storage, please consider to run [Codex node with marketplace support](/learn/run#codex-node-with-marketplace-support) or [Codex storage node](/learn/run#codex-storage-node).
```batch
if not exist %LOCALAPPDATA%\Codex mkdir %LOCALAPPDATA%\Codex
tar -xvf codex-%version%-%platform%-%architecture%-libs.zip -C %LOCALAPPDATA%\Codex
4. Rename binary and update user `path` variable ## Interact with Codex
```batch
:: Rename binary
move /Y %LOCALAPPDATA%\Codex\codex-%version%-%platform%-%architecture%.exe %LOCALAPPDATA%\Codex\codex.exe
:: Add folder to the path permanently When your Codex node is up and running you can interact with it using [Codex Marketplace UI](https://marketplace.codex.storage) for files sharing.
setx PATH %PATH%%LOCALAPPDATA%\Codex;
:: Add folder to the path for the current session Also, you can interact with Codex using [Codex API](/developers/api) and for a walk-through of the API, consider following the [Using Codex](/learn/using) guide.
PATH %PATH%%LOCALAPPDATA%\Codex;
```
4. Check the result ## Stay in touch
```shell
codex --version
```
```shell
Codex version: v0.1.4
Codex revision: 484124d
Nim Compiler Version 1.6.14 [Windows: amd64]
Compiled at 2024-06-27
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 38640664088251bbc88917b4bacfd86ec53014b8
active boot switches: -d:release
```
5. Cleanup Want to stay up-date, or looking for further assistance? Try our [discord-server](https://discord.gg/codex-storage).
```batch
del codex-%version%-%platform%-%architecture%-libs.zip ^
codex-%version%-%platform%-%architecture%-libs.zip.sha256
```
### Run Codex Ready to explore Codex functionality? Please [Join Codex Testnet](/networks/testnet).
To run your Codex node and join the testnet, follow the steps in the [codex-testnet-starter](https://github.com/codex-storage/codex-testnet-starter/blob/master/SETUP_HOME.md). If you want to run Codex locally without joining the Testnet, consider trying the [two-client-test](https://github.com/codex-storage/nim-codex/blob/master/docs/TwoClientTest.md) or the [marketplace-test](https://github.com/codex-storage/nim-codex/blob/master/docs/Marketplace.md).
If you want to run Codex locally without joining the testnet, consider trying the [two-client-test](https://github.com/codex-storage/nim-codex/blob/master/docs/TwoClientTest.md) or the [marketplace-test](https://github.com/codex-storage/nim-codex/blob/master/docs/Marketplace.md).
### Interact with Codex
When your Codex node is up and running you can interact with it using [Codex API](/developers/api).
For a walk-through of the API, consider following the [using-codex](https://github.com/codex-storage/codex-testnet-starter/blob/master/USINGCODEX.md) guide.
### Stay in touch
Want to stay up-date, or looking for further assistance? Try our [discord-server](https://discord.gg/codex-storage).