Documentation ¶
Overview ¶
Package VBGash implements the VBGash proof-of-work consensus engine.
Index ¶
- Variables
- func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int
- func MakeCache(block uint64, dir string)
- func MakeDataset(block uint64, dir string)
- func SeedHash(block uint64) []byte
- type API
- type Config
- type Mode
- type VBGash
- func (VBGash *VBGash) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (VBGash *VBGash) Author(header *types.Header) (common.Address, error)
- func (VBGash *VBGash) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (VBGash *VBGash) Close() error
- func (VBGash *VBGash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (VBGash *VBGash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (VBGash *VBGash) Hashrate() float64
- func (VBGash *VBGash) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (VBGash *VBGash) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (VBGash *VBGash) SealHash(header *types.Header) (hash common.Hash)
- func (VBGash *VBGash) SetThreads(threads int)
- func (VBGash *VBGash) Threads() int
- func (VBGash *VBGash) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
- func (VBGash *VBGash) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (VBGash *VBGash) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error
- func (VBGash *VBGash) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
Constants ¶
This section is empty.
Variables ¶
var ( FrontierBlockReward = big.NewInt(5e+18) // Block reward in wei for successfully mining a block ByzantiumBlockReward = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium ConstantinopleBlockReward = big.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Constantinople )
VBGash proof-of-work protocol constants.
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
Functions ¶
func CalcDifficulty ¶
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.
func MakeDataset ¶
MakeDataset generates a new VBGash dataset and optionally stores it to disk.
Types ¶
type API ¶
type API struct {
VBGash *VBGash
}
API exposes VBGash related mVBGods for the RPC interface.
func (*API) GVBGashrate ¶
GVBGashrate returns the current hashrate for local CPU miner and remote miner.
func (*API) GetWork ¶
GetWork returns a work package for external miner.
The work package consists of 3 strings:
result[0] - 32 bytes hex encoded current block header pow-hash result[1] - 32 bytes hex encoded seed hash used for DAG result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty result[3] - hex encoded block number
func (*API) SubmitHashRate ¶
SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined hash rate of all miners which submit work through this node.
It accepts the miner hash rate and an identifier which must be unique between nodes.
func (*API) SubmitWork ¶
SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was accepted. Note either an invalid solution, a stale work a non-existent work will return false.
type Config ¶
type Config struct { CacheDir string CachesInMem int CachesOnDisk int CachesLockMmap bool DatasetDir string DatasetsInMem int DatasetsOnDisk int DatasetsLockMmap bool PowMode Mode Log log.Logger `toml:"-"` }
Config are the configuration parameters of the VBGash.
type Mode ¶
type Mode uint
Mode defines the type and amount of PoW verification an VBGash engine makes.
type VBGash ¶
type VBGash struct {
// contains filtered or unexported fields
}
VBGash is a consensus engine based on proof-of-work implementing the VBGash algorithm.
func New ¶
New creates a full sized VBGash PoW scheme and starts a background thread for remote mining, also optionally notifying a batch of remote services of new work packages.
func NewFakeDelayer ¶
NewFakeDelayer creates a VBGash consensus engine with a fake PoW scheme that accepts all blocks as valid, but delays verifications by some time, though they still have to conform to the vbgloble consensus rules.
func NewFakeFailer ¶
NewFakeFailer creates a VBGash consensus engine with a fake PoW scheme that accepts all blocks as valid apart from the single one specified, though they still have to conform to the vbgloble consensus rules.
func NewFaker ¶
func NewFaker() *VBGash
NewFaker creates a VBGash consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the vbgloble consensus rules.
func NewFullFaker ¶
func NewFullFaker() *VBGash
NewFullFaker creates an VBGash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewShared ¶
func NewShared() *VBGash
NewShared creates a full sized VBGash PoW shared between all requesters running in the same process.
func NewTester ¶
NewTester creates a small sized VBGash PoW scheme useful only for testing purposes.
func (*VBGash) APIs ¶
func (VBGash *VBGash) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*VBGash) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*VBGash) CalcDifficulty ¶
func (VBGash *VBGash) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.
func (*VBGash) Finalize ¶
func (VBGash *VBGash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)
Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state on the header
func (*VBGash) FinalizeAndAssemble ¶
func (VBGash *VBGash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
FinalizeAndAssemble implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.
func (*VBGash) Hashrate ¶
Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute. Note the returned hashrate includes local hashrate, but also includes the total hashrate of all remote miner.
func (*VBGash) Prepare ¶
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the VBGash protocol. The changes are done inline.
func (*VBGash) Seal ¶
func (VBGash *VBGash) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal implements consensus.Engine, attempting to find a nonce that satisfies the block's difficulty requirements.
func (*VBGash) SetThreads ¶
SetThreads updates the number of mining threads currently enabled. Calling this mVBGod does not start mining, only sets the thread count. If zero is specified, the miner will use all cores of the machine. Setting a thread count below zero is allowed and will cause the miner to idle, without any work being done.
func (*VBGash) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*VBGash) VerifyHeader ¶
func (VBGash *VBGash) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
VerifyHeader checks whVBGer a header conforms to the consensus rules of the stock vbgloble VBGash engine.
func (*VBGash) VerifyHeaders ¶
func (VBGash *VBGash) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The mVBGod returns a quit channel to abort the operations and a results channel to retrieve the async verifications.
func (*VBGash) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whVBGer the given block satisfies the PoW difficulty requirements.
func (*VBGash) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock vbgloble VBGash engine.