2022-10-13 12:57:50 +00:00
# Gupax source files
* [Structure ](#Structure )
* [Bootstrap ](#Bootstrap )
2022-11-22 02:01:50 +00:00
* [Disk ](#Disk )
2022-10-17 02:28:41 +00:00
* [Scale ](#Scale )
2022-11-22 02:01:50 +00:00
* [Naming Scheme ](#naming-scheme )
2022-10-13 12:57:50 +00:00
## Structure
2022-11-22 02:01:50 +00:00
| File/Folder | Purpose |
|--------------|---------|
| constants.rs | General constants needed in Gupax
| command.rs | Code for executing/handling P2Pool/XMRig
| disk.rs | Code for writing to disk: `state.toml` , `node.toml` ; This holds the structs for mutable [State]
| ferris.rs | Cute crab bytes
| gupax.rs | `Gupax` tab
| main.rs | `App/Tab/State` + misc data/functions
| node.rs | Community node ping code for the `P2Pool` simple tab
| p2pool.rs | `P2Pool` tab
| status.rs | `Status` tab
| update.rs | Update code for the `Gupax` tab
| xmrig.rs | `XMRig` tab
2022-10-13 12:57:50 +00:00
## Bootstrap
2022-11-22 02:01:50 +00:00
This is how Gupax works internally when starting up:
2022-10-13 12:57:50 +00:00
1. **INIT**
2022-11-19 02:47:14 +00:00
- Initialize custom console logging with `log` , `env_logger`
- Initialize misc data (structs, text styles, thread count, images, etc)
- Check for admin privilege (for XMRig)
- Start initializing main `App` struct
- Parse command arguments
- Attempt to read disk files `state.toml` , `node.toml`
2022-10-13 12:57:50 +00:00
- If errors were found, pop-up window
2022-10-14 21:13:38 +00:00
2. **AUTO**
2022-11-19 02:47:14 +00:00
- If `auto_update` == `true` , spawn auto-updating thread
- If `auto_select` == `true` , spawn community node ping thread
2022-10-13 12:57:50 +00:00
3. **MAIN**
2022-11-19 02:47:14 +00:00
- All data should be initialized at this point, either via `state.toml` or default options
- Start `App` frame
- Do `App` stuff
- If `ask_before_quit` == `true` , ask before quitting
2022-10-13 12:57:50 +00:00
- Kill processes, kill connections, exit
2022-11-22 02:01:50 +00:00
## Disk
2022-11-23 04:21:46 +00:00
Long-term state is saved onto the disk in the "OS data folder", using the [TOML ](https://github.com/toml-lang/toml ) format. If not found, default files will be created. Given a slightly corrupted state file, Gupax will attempt to merge it with a new default one. This will most likely happen if the internal data structure of `state.toml` is changed in the future (e.g removing an outdated setting). Merging silently in the background is a good non-interactive way to handle this. The node/pool database cannot be merged, and if given a corrupted file, Gupax will show an un-recoverable error screen. If Gupax can't read/write to disk at all, or if there are any other big issues, it will show an un-recoverable error window.
2022-10-13 12:57:50 +00:00
2022-11-22 02:01:50 +00:00
| OS | Data Folder | Example |
|----------|----------------------------------------- |------------------------------------------------|
| Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Roaming\Gupax |
| macOS | `$HOME` /Library/Application Support | /Users/Alice/Library/Application Support/Gupax |
| Linux | `$XDG_DATA_HOME` or `$HOME` /.local/share | /home/alice/.local/share/gupax |
The current files saved to disk:
* `state.toml` Gupax state/settings
* `node.toml` The manual node database used for P2Pool advanced
2022-11-23 04:21:46 +00:00
* `pool.toml` The manual pool database used for XMRig advanced
2022-11-22 02:01:50 +00:00
Arti (Tor) also needs to save cache and state. It uses the same file/folder conventions (.local/arti, .cache/arti).
2022-10-17 02:28:41 +00:00
## Scale
Every frame, the max available `[width, height]` are calculated, and those are used as a baseline for the Top/Bottom bars, containing the tabs and status bar. After that, all available space is given to the middle ui elements. The scale is calculated every frame so that all elements can scale immediately as the user adjusts it; this doesn't take as much CPU as you might think since frames are only rendered on user interaction. Some elements are subtracted a fixed number because the `ui.seperator()` s add some fixed space which needs to be accounted for.
```
2022-11-23 04:21:46 +00:00
Main [App] outer frame (default: [1280.0, 800.0], 16:10 aspect ratio)
2022-11-19 02:47:14 +00:00
├─ TopPanel = height: 1/12th
├─ BottomPanel = height: 1/20th
├─ CentralPanel = height: the rest
2022-10-17 02:28:41 +00:00
```
2022-11-22 02:01:50 +00:00
## Naming Scheme
This is the internal naming scheme used by Gupax when updating/creating default folders/etc:
Windows:
2022-11-23 04:21:46 +00:00
- Gupax: `Gupax.exe`
- P2Pool: `P2Pool\p2pool.exe`
- XMRig: `XMRig\xmrig.exe`
2022-11-22 02:01:50 +00:00
macOS:
2022-11-23 04:21:46 +00:00
- Gupax: `Gupax.app/.../Gupax` (Gupax is packaged as an `.app` on macOS)
- P2Pool: `p2pool/p2pool`
- XMRig: `xmrig/xmrig`
2022-11-22 02:01:50 +00:00
Linux:
2022-11-23 04:21:46 +00:00
- Gupax: `gupax`
- P2Pool: `p2pool/p2pool`
- XMRig: `xmrig/xmrig`
2022-11-22 02:01:50 +00:00
These have to be packaged exactly with these names because the update code is case-sensitive. If an exact match is not found, it will error.
2022-11-22 18:18:18 +00:00
```
Package naming schemes:
gupax | gupax-vX.X.X-(windows|macos|linux)-x64(standalone|bundle).(zip|tar.gz)
p2pool | p2pool-vX.X.X-(windows|macos|linux)-x64.(zip|tar.gz)
xmrig | xmrig-X.X.X-(msvc-win64|macos-x64|linux-static-x64).(zip|tar.gz)
Download link = PREFIX + Version (found at runtime) + SUFFIX + Version + EXT
Example: https://github.com/hinto-janaiyo/gupax/releases/download/v0.0.1/gupax-v0.0.1-linux-standalone-x64.tar.gz
Exceptions (there are always exceptions...):
- XMRig doesn't have a [v], so it is [xmrig-6.18.0-...]
- XMRig separates the hash and signature
- P2Pool hashes are in UPPERCASE
```
2022-11-22 02:01:50 +00:00
For the Gupax data folder:
2022-11-23 04:21:46 +00:00
- Windows: `Gupax`
- macOS: `Gupax`
- Linux: `gupax`