sha256d

package
v0.0.0-...-4feef75 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const HashCountSpan uint32 = 200000

HashCountSpan counter big enough to avoid mutex bottleneck

View Source
const MaxNonce uint32 = 4294967295

MaxNonce standard value

Variables

View Source
var Psize = poolsize()

Psize size of the pool

Functions

func Gettarget

func Gettarget(difficulty utils.Difficulty) string

Gettarget TODO Calculate the right target depending on the difficulty. This one is totally made up for testing purpose.

Types

type CPUMiner

type CPUMiner struct {
	HashRate chan *HashRate
	// contains filtered or unexported fields
}

func NewCPUMiner

func NewCPUMiner(cfg *net.Config) (miner *CPUMiner)

func (*CPUMiner) Mine

func (miner *CPUMiner) Mine()

type Chunk

type Chunk struct {
	Block      block.Header
	Target     string
	StartNonce uint32
	EndNonce   uint32
	Valid      bool
}

Chunk entity defined by a block and a target. Nonce is here for checking if the chunk is valid

func NewChunkList

func NewChunkList(version byte, epoch uint32, difficulty utils.Difficulty) []Chunk

NewChunkList We are splitting a BlockHeader to spread the mining between the different goroutines

type Dispatcher

type Dispatcher struct {
	MiningPool    chan chan Chunk
	ChunkQueueIn  chan Chunk
	ChunkQueueOut chan Chunk
}

Dispatcher Entity. Contains a Pool of chans to send and receive from other miners. A queue of chunks to mine And a queue of chunks to validate and submit

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher element

func (*Dispatcher) Dispatch

func (dispatcher *Dispatcher) Dispatch()

Dispatch starts the counter for loging. Waits for chunk and send it to an available miner

func (*Dispatcher) Run

func (dispatcher *Dispatcher) Run()

Run starts the new dispatcher, create the miners, start them and begin dispatching.

type HashRate

type HashRate struct {
	Rate       float64
	CPUMinerID int
}

type Miner

type Miner struct {
	ID              int
	MiningPool      chan chan Chunk
	BlockChannelIn  chan Chunk
	BlockChannelOut chan Chunk
	// contains filtered or unexported fields
}

Miner entity defined by an ID. Worker.

func NewMiner

func NewMiner(id int, miningpool chan chan Chunk, outchan chan Chunk) Miner

NewMiner Creates Miner 'Worker'

func (Miner) Start

func (mine Miner) Start()

Start mining: receive block channels and execute them

func (Miner) Stop

func (mine Miner) Stop()

Stop tells the Miner to stop working

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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