transport

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package whatsminer provides a low-level API interface for Whatsminer ASICs. This package handles the core communication protocol, encryption, and token management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PKCS5UnPadding

func PKCS5UnPadding(src []byte) []byte

PKCS5UnPadding removes PKCS5 padding from a byte slice.

Types

type WhatsminerAPI

type WhatsminerAPI struct{}

WhatsminerAPI represents a stateless class with only class methods for read/write API calls.

func (*WhatsminerAPI) ExecCommand

func (w *WhatsminerAPI) ExecCommand(accessToken *WhatsminerAccessToken, cmd string, additionalParams map[string]any) (map[string]any, error)

ExecCommand sends a WRITEABLE API command.

func (*WhatsminerAPI) GetReadOnlyInfo

func (w *WhatsminerAPI) GetReadOnlyInfo(accessToken *WhatsminerAccessToken, cmd string, additionalParams map[string]any) (map[string]any, error)

GetReadOnlyInfo sends a READ-ONLY API command.

type WhatsminerAccessToken

type WhatsminerAccessToken struct {
	Created        time.Time
	IPAddress      string
	Port           int
	AdminPassword  string
	Cipher         cipher.Block
	Sign           string
	OnRefreshError func(err error)
	// contains filtered or unexported fields
}

WhatsminerAccessToken represents a reusable token to access and/or control a single Whatsminer ASIC.

func NewWhatsminerAccessToken

func NewWhatsminerAccessToken(ipAddress string, port int, adminPassword string) (*WhatsminerAccessToken, error)

NewWhatsminerAccessToken creates a new instance of WhatsminerAccessToken.

func (*WhatsminerAccessToken) Close

func (t *WhatsminerAccessToken) Close()

Close stops the background token refresh goroutine.

func (*WhatsminerAccessToken) EnableWriteAccess

func (t *WhatsminerAccessToken) EnableWriteAccess(adminPassword string) error

EnableWriteAccess enables write access for the token and starts the background refresh.

func (*WhatsminerAccessToken) HasWriteAccess

func (t *WhatsminerAccessToken) HasWriteAccess() error

HasWriteAccess checks write access and refreshes the token if necessary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL