"""BlockHeader model — block header from the Ergo Node API."""

from typing import Optional

from pydantic import BaseModel, Field

from boxtime.models.node.pow_solutions import PowSolutions


class BlockHeader(BaseModel):
    """``BlockHeader`` in the spec."""

    id: str
    timestamp: int
    version: int
    ad_proofs_root: str = Field(alias="adProofsRoot")
    state_root: str = Field(alias="stateRoot")
    transactions_root: str = Field(alias="transactionsRoot")
    n_bits: int = Field(alias="nBits")
    extension_hash: str = Field(alias="extensionHash")
    pow_solutions: PowSolutions = Field(alias="powSolutions")
    height: int
    difficulty: str
    parent_id: str = Field(alias="parentId")
    votes: str
    size: Optional[int] = Field(default=None)
    extension_id: Optional[str] = Field(default=None, alias="extensionId")
    transactions_id: Optional[str] = Field(default=None, alias="transactionsId")
    ad_proofs_id: Optional[str] = Field(default=None, alias="adProofsId")
