miner-api 0.1.0

Instructions, state and SDK for the MINER protocol - a proof-of-work mined SPL token where holdings boost mining power
Documentation
/// Tagi instrukcji (pierwszy bajt danych).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum MinerInstruction {
    /// Inicjalizacja programu.
    /// Konta: [admin (signer, payer), config (PDA), mint, round0 (PDA),
    ///         system_program]
    /// Wymagania wobec minta (tworzonego poza programem przed initialize):
    /// decimals = 9, mint_authority = PDA "treasury", freeze_authority = None.
    Initialize = 0,

    /// Rejestracja minera.
    /// Konta: [authority (signer, payer), miner (PDA), slot_hashes, system_program]
    Register = 1,

    /// Ustawienie session keya (podpisuje submity w tle).
    /// Konta: [authority (signer), miner]
    /// Dane: session_key [u8;32] (zera = odwołanie)
    AuthorizeSession = 2,

    /// Submit hasha (raz na rundę): weryfikacja PoW, naliczenie wagi,
    /// rozliczenie poprzedniej rundy (lazy).
    /// Konta: [signer (authority lub session), miner, config,
    ///         current_round, prev_round, token_account (ATA authority),
    ///         slot_hashes]
    /// Dane: nonce u64 LE
    Mine = 3,

    /// Odbiór naliczonych nagród (mint do ATA authority).
    /// Konta: [authority (signer), miner, config, prev_round, mint,
    ///         treasury (PDA), token_account (ATA authority), token_program]
    Claim = 4,

    /// Zamknięcie rundy i otwarcie kolejnej (permissionless crank).
    /// Konta: [payer (signer), config, new_round (PDA), system_program]
    Crank = 5,

    /// Zamknięcie starego konta rundy po retencji (rent dla wołającego).
    /// Konta: [recipient (signer), config, round]
    CloseRound = 6,

    /// Zmiana parametrów przez admina.
    /// Konta: [admin (signer), config]
    /// Dane: min_difficulty u64 LE, base_weight u64 LE, round_seconds u64 LE
    UpdateConfig = 7,

    /// Przekazanie roli admina (docelowo: multisig z timelockiem).
    /// Konta: [admin (signer), config]
    /// Dane: new_admin [u8;32]
    SetAdmin = 8,
}

impl MinerInstruction {
    pub fn from_u8(v: u8) -> Option<Self> {
        Some(match v {
            0 => Self::Initialize,
            1 => Self::Register,
            2 => Self::AuthorizeSession,
            3 => Self::Mine,
            4 => Self::Claim,
            5 => Self::Crank,
            6 => Self::CloseRound,
            7 => Self::UpdateConfig,
            8 => Self::SetAdmin,
            _ => return None,
        })
    }
}