miner

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEpochNumber = 2016
	DefaultEpochTarget = 1_209_600_000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DifficultyAdjustment added in v0.6.0

type DifficultyAdjustment struct {
	Numerator   int64
	Denominator int64
}

type DifficultyMetrics

type DifficultyMetrics struct {
	LeadingZeros     int64
	DifficultyNumber int64
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func GetManager

func GetManager() *Manager

func (*Manager) Reset

func (m *Manager) Reset()

func (*Manager) Start

func (m *Manager) Start(blockData any)

func (*Manager) Stop

func (m *Manager) Stop()

type Miner

type Miner struct {
	Config *config.Config
	// contains filtered or unexported fields
}

func New

func New(
	waitGroup *sync.WaitGroup,
	resultChan chan Result,
	doneChan chan any,
	blockData any,
	hashCounter *atomic.Uint64,
) *Miner

func (*Miner) Start

func (m *Miner) Start()

type Result

type Result struct {
	BlockData any
	Nonce     [16]byte
}

type TargetState added in v0.3.0

type TargetState interface {
	MarshalCBOR() ([]byte, error)
	SetNonce([16]byte)
	GetNonce() [16]byte
}

type TargetStateV1 added in v0.3.0

type TargetStateV1 struct {
	Nonce            [16]byte
	BlockNumber      int64
	CurrentHash      []byte
	LeadingZeros     int64
	DifficultyNumber int64
	EpochTime        int64
}

func (*TargetStateV1) GetNonce added in v0.3.0

func (t *TargetStateV1) GetNonce() [16]byte

func (*TargetStateV1) MarshalCBOR added in v0.3.0

func (state *TargetStateV1) MarshalCBOR() ([]byte, error)

func (*TargetStateV1) SetNonce added in v0.3.0

func (t *TargetStateV1) SetNonce(nonce [16]byte)

type TargetStateV2 added in v0.5.0

type TargetStateV2 struct {
	Nonce            [16]byte
	MinerCredHash    []byte
	EpochTime        int64
	BlockNumber      int64
	CurrentHash      []byte
	LeadingZeros     int64
	DifficultyNumber int64
	// contains filtered or unexported fields
}

func (*TargetStateV2) GetNonce added in v0.5.0

func (t *TargetStateV2) GetNonce() [16]byte

func (*TargetStateV2) MarshalCBOR added in v0.5.0

func (state *TargetStateV2) MarshalCBOR() ([]byte, error)

func (*TargetStateV2) SetNonce added in v0.5.0

func (t *TargetStateV2) SetNonce(nonce [16]byte)

Jump to

Keyboard shortcuts

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