2022-10-13 12:57:50 +00:00
# Gupax source files
* [Structure ](#Structure )
* [Bootstrap ](#Bootstrap )
2022-10-14 21:13:38 +00:00
* [State ](#State )
2022-10-13 12:57:50 +00:00
## Structure
| File/Folder | Purpose |
|----------------|---------|
| `constants.rs` | General constants needed in Gupax
2022-10-17 00:36:58 +00:00
| `gupax.rs` | Impl for `Gupax` tab
2022-10-13 12:57:50 +00:00
| `main.rs` | Struct/enum/impl for `App/Tab/State` , init functions, main function
2022-10-14 21:13:38 +00:00
| `node.rs` | Struct/impl for Community Nodes
2022-10-17 00:36:58 +00:00
| `p2pool.rs` | Impl for `P2Pool` tab
| `state.rs` | Struct/impl for `gupax.toml` , the disk state. This holds the structs representing tabs with mutable state (Gupax/P2Pool/XMRig)
2022-10-13 12:57:50 +00:00
| `status.rs` | Struct/impl for `Status` tab
2022-10-17 00:36:58 +00:00
| `xmrig.rs` | Impl for `XMRig` tab
2022-10-13 12:57:50 +00:00
## Bootstrap
This is how Gupax works internally when starting up, divided into 3 sections.
1. **INIT**
- Initialize custom console logging with `log` , `env_logger` || *warn!*
- Initialize misc data (structs, text styles, thread count, images, etc) || *panic!*
- Check for admin privilege (for XMRig) || *warn!*
- Attempt to read `gupax.toml` || *warn!* , *initialize config with default options*
- If errors were found, pop-up window
2022-10-14 21:13:38 +00:00
2. **AUTO**
2022-10-13 12:57:50 +00:00
- If `auto_update` == `true` , pop-up auto-updating window || *info!* , *skip auto-update*
- Multi-threaded GitHub API check on Gupax -> P2Pool -> XMRig || *warn!* , *skip auto-update*
- Multi-threaded download if current version != new version || *warn!* , *skip auto-update*
- After download, atomically replace current binaries with new || *warn!* , *skip auto-update*
- Update version metadata || *warn!* , *skip auto-update*
2022-10-14 21:13:38 +00:00
- If `auto_select` == `true` , ping community nodes and select fastest one || *warn!*
2022-10-13 12:57:50 +00:00
3. **MAIN**
- All data must be initialized at this point, either via `gupax.toml` or default options || *panic!*
- Start `App` frame || *panic!*
- Write state to `gupax.toml` on user clicking `Save` (after checking input for correctness) || *warn!*
- If `ask_before_quit` == `true` , check for running processes, unsaved state, and update connections before quitting
- Kill processes, kill connections, exit
## State
2022-10-15 19:15:27 +00:00
Internal state is saved in the "OS data folder" as `gupax.toml` , using the [TOML ](https://github.com/toml-lang/toml ) format. If the version can't be parsed (not in the `vX.X.X` or `vX.X` format), the auto-updater will be skipped. [If not found, a default `gupax.toml` file will be created with `State::default`. ](https://github.com/hinto-janaiyo/gupax/blob/main/src/state.rs ) Gupax will `panic!` if `gupax.toml` has IO or parsing issues.
2022-10-13 12:57:50 +00:00
| OS | Data Folder | Example |
|----------|----------------------------------------- |-----------------------------------------------------------|
| Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Roaming\Gupax\gupax.toml |
| macOS | `$HOME` /Library/Application Support | /Users/Alice/Library/Application Support/Gupax/gupax.toml |
| Linux | `$XDG_DATA_HOME` or `$HOME` /.local/share | /home/alice/.local/share/gupax/gupax.toml |