controller

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: ISC Imports: 15 Imported by: 0

README

controller

ISC License GoDoc

Overview

This is a miner controller that implements an ultra low-latency mining control system for external stand-alone CPU miners connected by KCP reliable UDP protocol to cope with the high block rate that helps protect the network from botnets, pools, and allows the creation of larger clusters of mining computers.

Installation and Updating

$ go get -u git.parallelcoin.io/dev/9/mining/controller

License

Package controller is licensed under the copyfree ISC License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = cl.NewSubSystem("chain/mining/dispatch", ll.DEFAULT)

Log is the logger for the peer package

Functions

func UseLogger

func UseLogger(
	logger *cl.SubSystem)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using log.

Types

type Address

type Address struct {
	Address string
}

type Config

type Config struct {

	// Blockchain gives access for the miner to information about the chain
	Blockchain *blockchain.BlockChain

	// ChainParams identifies which chain parameters the cpu miner is associated with.
	ChainParams *chaincfg.Params

	// BlockTemplateGenerator identifies the instance to use in order to generate block templates that the miner will attempt to solve.
	BlockTemplateGenerator *mining.BlkTmplGenerator

	// MiningAddrs is a list of payment addresses to use for the generated blocks.  Each generated block will randomly choose one of thec.
	MiningAddrs []util.Address

	// ProcessBlock defines the function to call with any solved blocks. It typically must run the provided block through the same set of rules and handling as any other block coming from the network.
	ProcessBlock func(*util.Block, blockchain.BehaviorFlags) (bool, error)

	// MinerListener is the listener that will accept miner subscriptions and such
	MinerListener string

	// MinerKey is generated from the password specified in the main configuration for miner port using Stribog hash to derive the nonce, Argon2i to expand the password, and a final pass of Keccak
	MinerKey []byte

	// ConnectedCount defines the function to use to obtain how many other peers the server is connected to.  This is used by the automatic persistent mining routine to determine whether or it should attempt mining.  This is useful because there is no point in mining when not connected to any peers since there would no be anyone to send any found blocks to.
	ConnectedCount func() int32

	// IsCurrent defines the function to use to obtain whether or not the block chain is current.  This is used by the automatic persistent mining routine to determine whether or it should attempt mining. This is useful because there is no point in mining if the chain is not current since any solved blocks would be on a side chain and and up orphaned anyways.
	IsCurrent func() bool
}

type Controller

type Controller struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(
	cfg *Config) *Controller

New returns a new instance of a CPU miner for the provided configuration. Use Start to begin the mining process. See the documentation for Controller type for more details.

func (*Controller) IsMining

func (c *Controller) IsMining() bool

IsMining returns whether or not the miner controller has been started and is therefore currenting mining. This function is safe for concurrent access.

func (*Controller) Start

func (c *Controller) Start()

Start begins the miner controller process. Calling this function when the miner controller has already been started will have no effect.

func (*Controller) Stop

func (c *Controller) Stop()

Stop gracefully stops the mining process by signalling all workers, and the speed monitor to quit. Calling this function when the miner controller has not already been started will have no effect.

type Kopach

type Kopach []Address

func (*Kopach) Subscribe

func (k *Kopach) Subscribe(args *Address, reply *Address) (err error)

Subscribe adds an address to the list of subscribers to push work to

func (*Kopach) Unsubscribe

func (k *Kopach) Unsubscribe(args *Address, reply *Address) (err error)

Unsubscribe removes an address from the list of subscribers to push work to

type Work

type Work struct {
	PrevBlockHash *chainhash.Hash
	MerkleRoot    *chainhash.Hash
	TimeStamp     uint32
	Difficulties  [9]uint32
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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