Documentation ¶
Index ¶
- func CreateNewKey(filePath, password string) (accounts.Account, error)
- func ExportPrivateKey(ks *keystore.KeyStore, account accounts.Account, password string) (string, error)
- func GetPublicIP() (string, error)
- func GetSystemServiceTypes(endpoint string) ([]uint64, error)
- func IsMinerRegistered(endpoint string, minerAddress string) (bool, error)
- func LoadKey(filePath, password string) (accounts.Account, error)
- func PromptPassword(confirm bool) (string, error)
- func QueryRPC(endpoint string, queryContent string) (string, error)
- func QueryRPCStatus(rpcEndpoint string) error
- type Miner
- type MinerRegistrationRequest
- type MinerResponse
- type RPCResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNewKey ¶
CreateNewKey generates a new key and stores it in a keystore file, returning the account.
func ExportPrivateKey ¶
func ExportPrivateKey(ks *keystore.KeyStore, account accounts.Account, password string) (string, error)
ExportPrivateKey exports the private key for a given account from the keystore
func GetPublicIP ¶
func GetSystemServiceTypes ¶
GetSystemServiceTypes - Simulates retrieving service types.
func IsMinerRegistered ¶
IsMinerRegistered checks if a miner is registered in the network
func LoadKey ¶
LoadKey loads a key from a keystore file using the provided password and returns the account.
func PromptPassword ¶
PromptPassword requests a password from the user and optionally confirms it.
func QueryRPCStatus ¶
QueryRPCStatus sends a GET request to the RPC endpoint and checks the response
Types ¶
type Miner ¶
type Miner struct { RPCStatus int // 0 for stale, 1 for active RPCEndpoint string Wallet struct { Keystore *keystore.KeyStore Password string } KeyFilePath string IP string `json:"ip"` Status uint8 `json:"status"` MinerName string `json:"miner_name"` ServiceTypes []uint64 `json:"service_types"` ServicePort uint64 `json:"service_port"` }
func (*Miner) Initialize ¶
Initialize checks or creates a key, sets up the wallet, and updates the RPC status
func (*Miner) RegisterMiner ¶
func (*Miner) ToAddress ¶
ToAddress returns the Ethereum address associated with the miner's primary account. It creates a new account if none exist in the keystore.
func (*Miner) ToAddressHex ¶
ToAddressHex returns the Ethereum address in hexadecimal string format
func (*Miner) UpdateRPCStatus ¶
UpdateRPCStatus checks the RPC status and updates the Miner struct
type MinerRegistrationRequest ¶
type MinerRegistrationRequest struct { MinerName string `json:"miner_name"` // The name of the miner ServiceTypes []uint64 `json:"service_types"` // An array of service type identifiers ServicePort uint64 `json:"service_port"` // The network port the miner uses IP string `json:"ip"` // The IP address of the miner Status uint8 `json:"status"` // The operational status of the miner }
MinerRegistrationRequest represents the data required to register a miner.
type MinerResponse ¶
type MinerResponse struct { Jsonrpc string `json:"jsonrpc"` ID int `json:"id"` Result struct { Response struct { Code int `json:"code"` Log string `json:"log"` Key string `json:"key"` Value string `json:"value"` Height string `json:"height"` ProofOps interface{} `json:"proofOps"` Codespace string `json:"codespace"` } `json:"response"` } `json:"result"` }
MinerResponse defines the JSON response structure for miner registration checks
type RPCResponse ¶
type RPCResponse struct { Jsonrpc string `json:"jsonrpc"` ID int `json:"id"` Result struct { NodeInfo struct { ProtocolVersion struct { P2P string `json:"p2p"` Block string `json:"block"` App string `json:"app"` } `json:"protocol_version"` ID string `json:"id"` ListenAddr string `json:"listen_addr"` Network string `json:"network"` Version string `json:"version"` Channels string `json:"channels"` Moniker string `json:"moniker"` Other struct { TxIndex string `json:"tx_index"` RPCAddress string `json:"rpc_address"` } `json:"other"` } `json:"node_info"` SyncInfo struct { LatestBlockHash string `json:"latest_block_hash"` LatestAppHash string `json:"latest_app_hash"` LatestBlockHeight string `json:"latest_block_height"` LatestBlockTime string `json:"latest_block_time"` EarliestBlockHash string `json:"earliest_block_hash"` EarliestAppHash string `json:"earliest_app_hash"` EarliestBlockHeight string `json:"earliest_block_height"` EarliestBlockTime string `json:"earliest_block_time"` CatchingUp bool `json:"catching_up"` } `json:"sync_info"` ValidatorInfo struct { Address string `json:"address"` PubKey struct { Type string `json:"type"` Value string `json:"value"` } `json:"pub_key"` VotingPower string `json:"voting_power"` } `json:"validator_info"` } `json:"result"` }
RPCResponse defines the expected JSON response structure