Documentation ¶
Overview ¶
Package ethash implements the ethash proof-of-work consensus engine.
Index ¶
- Constants
- Variables
- func CalcBaseFee(config *ethparams.ChainConfig, parent *Header) *big.Int
- func MakeGlobalEthash(dir string)
- func VerifyEip1559Header(config *ethparams.ChainConfig, parent, header *Header) error
- func VerifySeal(header *Header) error
- type Cache
- type Config
- type Ethash
- type Header
- type HeaderStore
- func (hs *HeaderStore) CurrentHash() common.Hash
- func (hs *HeaderStore) CurrentNumber() uint64
- func (hs *HeaderStore) DeleteCanonicalHash(number uint64, db types.StateDB)
- func (hs *HeaderStore) GetCurrentNumberAndHash(db types.StateDB) (uint64, common.Hash, error)
- func (hs *HeaderStore) GetHashByNumber(db types.StateDB, number uint64) (common.Hash, error)
- func (hs *HeaderStore) GetHeader(hash common.Hash, number uint64, db types.StateDB) *Header
- func (hs *HeaderStore) GetHeaderByNumber(number uint64, db types.StateDB) *Header
- func (hs *HeaderStore) GetTd(hash common.Hash, number uint64, db types.StateDB) *big.Int
- func (hs *HeaderStore) HasHeader(hash common.Hash, number uint64, db types.StateDB) bool
- func (hs *HeaderStore) InsertHeaders(db types.StateDB, ethHeaders []byte) ([]*params.NumberHash, error)
- func (hs *HeaderStore) Load(state types.StateDB) (err error)
- func (hs *HeaderStore) LoadCanonicalHash(number uint64, db types.StateDB) (lh common.Hash, err error)
- func (hs *HeaderStore) LoadHeader(number uint64, db types.StateDB) (lh *LightHeader, err error)
- func (hs *HeaderStore) ReadCanonicalHash(number uint64, db types.StateDB) common.Hash
- func (hs *HeaderStore) ResetHeaderStore(state types.StateDB, ethHeaders []byte, td *big.Int) error
- func (hs *HeaderStore) Store(state types.StateDB) error
- func (hs *HeaderStore) StoreCanonicalHash(state types.StateDB, number uint64, hash *common.Hash) error
- func (hs *HeaderStore) StoreHeader(state types.StateDB, number uint64, header *LightHeader) error
- func (hs *HeaderStore) WriteCanonicalHash(hash common.Hash, number uint64, db types.StateDB)
- func (hs *HeaderStore) WriteHeaderAndTd(hash common.Hash, number uint64, td *big.Int, header *Header, db types.StateDB) error
- func (hs *HeaderStore) WriteHeaders(db types.StateDB, ethHeaders []byte) (*headerWriteResult, error)
- type LightHeader
- type Mode
- type TxProve
- type Validate
- type Verify
- type WriteStatus
Constants ¶
View Source
const ( StoreCacheSize = 20 MaxHeaderLimit = 100000 SplicingSymbol = "-" )
Variables ¶
View Source
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
Functions ¶
func CalcBaseFee ¶
func CalcBaseFee(config *ethparams.ChainConfig, parent *Header) *big.Int
CalcBaseFee calculates the basefee of the header.
func MakeGlobalEthash ¶
func MakeGlobalEthash(dir string)
func VerifyEip1559Header ¶
func VerifyEip1559Header(config *ethparams.ChainConfig, parent, header *Header) error
func VerifySeal ¶
Types ¶
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 ethash.
type Ethash ¶
type Ethash struct {
// contains filtered or unexported fields
}
Ethash is a consensus engine based on proof-of-work implementing the ethash algorithm.
type Header ¶
type Header struct { ParentHash common.Hash `json:"parentHash" gencodec:"required"` UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` Coinbase common.Address `json:"miner" gencodec:"required"` Root common.Hash `json:"stateRoot" gencodec:"required"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` Bloom types.Bloom `json:"logsBloom" gencodec:"required"` Difficulty *big.Int `json:"difficulty" gencodec:"required"` Number *big.Int `json:"number" gencodec:"required"` GasLimit uint64 `json:"gasLimit" gencodec:"required"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` Time uint64 `json:"timestamp" gencodec:"required"` Extra []byte `json:"extraData" gencodec:"required"` MixDigest common.Hash `json:"mixHash"` Nonce types.BlockNonce `json:"nonce"` // BaseFee was added by EIP-1559 and is ignored in legacy headers. BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` }
type HeaderStore ¶
func NewHeaderStore ¶
func NewHeaderStore() *HeaderStore
func (*HeaderStore) CurrentHash ¶
func (hs *HeaderStore) CurrentHash() common.Hash
func (*HeaderStore) CurrentNumber ¶
func (hs *HeaderStore) CurrentNumber() uint64
func (*HeaderStore) DeleteCanonicalHash ¶
func (hs *HeaderStore) DeleteCanonicalHash(number uint64, db types.StateDB)
func (*HeaderStore) GetCurrentNumberAndHash ¶
func (*HeaderStore) GetHashByNumber ¶
func (*HeaderStore) GetHeaderByNumber ¶
func (hs *HeaderStore) GetHeaderByNumber(number uint64, db types.StateDB) *Header
func (*HeaderStore) InsertHeaders ¶
func (hs *HeaderStore) InsertHeaders(db types.StateDB, ethHeaders []byte) ([]*params.NumberHash, error)
func (*HeaderStore) LoadCanonicalHash ¶
func (*HeaderStore) LoadHeader ¶
func (hs *HeaderStore) LoadHeader(number uint64, db types.StateDB) (lh *LightHeader, err error)
func (*HeaderStore) ReadCanonicalHash ¶
func (*HeaderStore) ResetHeaderStore ¶
func (*HeaderStore) StoreCanonicalHash ¶
func (*HeaderStore) StoreHeader ¶
func (hs *HeaderStore) StoreHeader(state types.StateDB, number uint64, header *LightHeader) error
func (*HeaderStore) WriteCanonicalHash ¶
func (*HeaderStore) WriteHeaderAndTd ¶
func (*HeaderStore) WriteHeaders ¶
func (hs *HeaderStore) WriteHeaders(db types.StateDB, ethHeaders []byte) (*headerWriteResult, error)
type LightHeader ¶
type Mode ¶
type Mode uint
Mode defines the type and amount of PoW verification an ethash engine makes.
type Validate ¶
type Validate struct{}
func (*Validate) ValidateHeaderChain ¶
func (*Validate) VerifyHeaders ¶
type WriteStatus ¶
type WriteStatus byte
WriteStatus status of write
const ( NonStatTy WriteStatus = iota CanonStatTy SideStatTy )
Click to show internal directories.
Click to hide internal directories.