Mining/pkg/mining/mining_profile.go
Virgil 68c826a3d8
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Align mining AX naming and comments
2026-04-04 05:33:08 +00:00

31 lines
1 KiB
Go

package mining
// var rawConfig RawConfig
// _ = json.Unmarshal([]byte(`{"pool":"pool.lthn.io:3333"}`), &rawConfig)
type RawConfig []byte
// profile := MiningProfile{ID: "abc", Name: "LTHN RandomX", MinerType: "xmrig", Config: rawConfig}
// manager.SaveProfile(profile)
type MiningProfile struct {
ID string `json:"id"`
Name string `json:"name"`
MinerType string `json:"minerType"` // Miner type such as `xmrig` or `ttminer`.
Config RawConfig `json:"config" swaggertype:"object"` // Raw JSON config for the selected miner profile.
}
// data, err := profile.Config.MarshalJSON() // returns the config blob unchanged.
func (m RawConfig) MarshalJSON() ([]byte, error) {
if m == nil {
return []byte("null"), nil
}
return m, nil
}
// if err := json.Unmarshal(rawConfig, &profile.Config); err != nil { ... }
func (m *RawConfig) UnmarshalJSON(data []byte) error {
if m == nil {
return ErrInternal("RawConfig: UnmarshalJSON on nil pointer")
}
*m = append((*m)[0:0], data...)
return nil
}