octell

package
v0.0.0-...-de85661 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Unlicense Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FrontierBlockReward       = big.NewInt(5e+18) // wei成功挖掘区块的区块奖励
	ByzantiumBlockReward      = big.NewInt(3e+18) // wei成功从拜占庭向上挖掘一个区块的区块奖励
	ConstantinopleBlockReward = big.NewInt(2e+18) // wei成功从君士坦丁堡向上挖掘一个区块的区块奖励

)
View Source
var ErrInvalidDumpMagic = errors.New("invalid dump magic")

Functions

func CalcDifficulty

func CalcDifficulty(config *entity.ChainConfig, time uint64, parent *block2.Header) *big.Int

CalcDifficulty是难度调整算法。它返回在给定父块的时间和难度的时间创建新块时应具有的难度。

func CreateOctell

func CreateOctell(chainConfig *entity.ChainConfig, config *Config) consensus.Engine

func SeedHash

func SeedHash(block uint64) []byte

SeedHash是用于生成验证缓存和挖掘数据集的种子。

Types

type API

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

API exposes ethash related methods for the RPC interface.

func (*API) GetWork

func (api *API) GetWork() ([4]string, error)

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

func (api *API) SubmitHashrate(rate hexutil.Uint64, id entity.Hash) bool

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

func (api *API) SubmitWork(nonce block.BlockNonce, hash, digest entity.Hash) bool

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

	// 设置后,远程密封器发送的通知将是块头JSON对象,而不是工作包数组。
	NotifyFull bool
}

Config是octell的配置参数。

type Mode

type Mode uint

模式定义octell引擎进行的PoW验证的类型和数量。

const (
	ModeNormal Mode = iota
	ModeShared
	ModeTest
	ModeFake
	ModeFullFake
)

type Octell

type Octell struct {
	Config *Config //`autoInjectLang:"octell.Config"` //启动项配置
	// contains filtered or unexported fields
}

Octell是一个基于实现Octell算法的工作证明的共识引擎。

func New

func New(config *Config, notify []string, noverify bool) *Octell

New创建一个全尺寸的octell PoW方案,并启动用于远程挖掘的后台线程,还可以选择通知一批远程服务新的工作包。

func (*Octell) APIs

func (o *Octell) APIs(chain consensus.ChainHeaderReader) []rpc.API

API实现共识。引擎,返回面向用户的RPC API。

func (*Octell) Author

func (o *Octell) Author(header *block2.Header) (entity.Address, error)

作者实现共识。引擎,返回标题的coinbase作为工作证明,以验证块的作者。

func (*Octell) CalcDifficulty

func (octell *Octell) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *block2.Header) *big.Int

CalcDifficulty是难度调整算法。它返回在给定父块的时间和难度的时间创建新块时应具有的难度。

func (*Octell) Close

func (o *Octell) Close() error

关闭关闭退出通道以通知所有后端线程退出。

func (*Octell) Finalize

func (octell *Octell) Finalize(chain consensus.ChainHeaderReader, header *block2.Header, ob *operationdb.OperationDB, txs []*block2.Transaction, uncles []*block2.Header)

Finalize实现共识。引擎,累积积木和叔叔奖励,设置标题的最终状态

func (*Octell) FinalizeAndAssemble

func (o *Octell) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *block2.Header, ob *operationdb.OperationDB, txs []*block2.Transaction, uncles []*block2.Header, receipts []*block2.Receipt) (*block2.Block, error)

FinalizeAndAssemble 实现共识。引擎,累积积木和叔叔奖励,设置最终状态并组装积木。

func (*Octell) Prepare

func (octell *Octell) Prepare(chain consensus.ChainHeaderReader, header *block2.Header) error

Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the ethash protocol. The changes are done inline.

func (*Octell) Seal

func (o *Octell) Seal(chain consensus.ChainHeaderReader, b *block2.Block, results chan<- *block2.Block, stop <-chan struct{}) error

Seal实现共识。引擎,试图找到满足模块难度要求的nonce。

func (*Octell) SealHash

func (octell *Octell) SealHash(header *block2.Header) (hash entity.Hash)

SealHash返回块在被密封之前的哈希值。

func (*Octell) SetThreads

func (octell *Octell) SetThreads(threads int)

SetThreads更新当前启用的挖掘线程数。 调用此方法不会开始挖掘,只会设置线程数。 如果指定为零,矿工将使用机器的所有芯。允许将线程数设置为零以下,并将导致矿工闲置,而不进行任何工作。

func (*Octell) StopRemoteSealer

func (o *Octell) StopRemoteSealer() error

StopRemoteSealer停止远程密封

func (*Octell) VerifyHeader

func (o *Octell) VerifyHeader(chain consensus.ChainHeaderReader, header *block2.Header, seal bool) error

VerifyHeader检查标头是否符合股票以太坊ethash引擎的共识规则。

func (*Octell) VerifyHeaders

func (o *Octell) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*block2.Header, seals []bool) (chan<- struct{}, <-chan error)

VerifyHeaders与VerifyHeader类似,但同时验证一批标头。该方法返回退出通道以中止操作,返回结果通道以检索异步验证。

type OctellStart

type OctellStart struct {
}

func (OctellStart) Start

func (os OctellStart) Start()

Jump to

Keyboard shortcuts

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