datong

package
v3.6.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: GPL-3.0, LGPL-3.0, LGPL-3.0-or-later Imports: 26 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CheckPoints    map[uint64]common.Hash
	LastCheckPoint uint64
)
View Source
var (
	ErrNoTicket = errors.New("Miner doesn't have ticket")
)
View Source
var (
	MinBlockTime int64 = 7 // 7 seconds

)

Functions

func ApplyVote1HardFork

func ApplyVote1HardFork(statedb *state.StateDB, blockNumber *big.Int, timestamp uint64)

-------------------------- vote1 fork -------------------------

func CalcRewards

func CalcRewards(height *big.Int) *big.Int

func CheckAddingReport

func CheckAddingReport(state vm.StateDB, report []byte, blockNumber *big.Int) (*types.Header, *types.Header, error)

func CheckPoint

func CheckPoint(blockHeight uint64, blockHash common.Hash) (isInRange bool, err error)

func DecodeLogData

func DecodeLogData(data []byte) (interface{}, error)

func DecodePunishTickets

func DecodePunishTickets(data []byte) ([]common.Hash, error)

func DecodeReport

func DecodeReport(report []byte) (*types.Header, *types.Header, error)

func DecodeTxInput

func DecodeTxInput(input []byte) (interface{}, error)

func GenerateGenesisExtraData

func GenerateGenesisExtraData(old []byte, ticketNumber uint64) []byte

func InitCheckPoints

func InitCheckPoints(file string)

func IsInCheckPointsRange

func IsInCheckPointsRange(blockHeight uint64) bool

func ProcessReport

func ProcessReport(heade1, header2 *types.Header, reporter common.Address, state vm.StateDB, height *big.Int, timestamp uint64) []common.Hash

punish miner and reward reporter

func ReportIllegal

func ReportIllegal(header1, header2 *types.Header)

func SetHeaders

func SetHeaders(parents []*types.Header)

func VerifySignature

func VerifySignature(header *types.Header) error

Types

type API

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

API wacom

func (*API) GetSnapshot

func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)

GetSnapshot wacom

func (*API) GetSnapshotAtHash

func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)

GetSnapshotAtHash wacom

type DaTong

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

DaTong wacom

func New

func New(config *params.DaTongConfig, db ethdb.Database) *DaTong

New wacom

func (*DaTong) APIs

func (dt *DaTong) APIs(chain consensus.ChainReader) []rpc.API

APIs returns the RPC APIs this consensus engine provides.

func (*DaTong) Author

func (dt *DaTong) Author(header *types.Header) (common.Address, error)

Author retrieves the Ethereum address of the account that minted the given block, which may be different from the header's coinbase if a consensus engine is based on signatures.

func (*DaTong) Authorize

func (dt *DaTong) Authorize(signer common.Address, signFn SignerFn)

Authorize wacom

func (*DaTong) CalcDifficulty

func (dt *DaTong) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have.

func (*DaTong) Close

func (dt *DaTong) Close() error

Close terminates any background threads maintained by the consensus engine.

func (*DaTong) Finalize

func (dt *DaTong) Finalize(chain consensus.ChainReader, header *types.Header, statedb *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

Finalize runs any post-transaction state modifications (e.g. block rewards) and assembles the final block. Note: The block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).

func (*DaTong) PreProcess

func (c *DaTong) PreProcess(chain consensus.ChainReader, header *types.Header, statedb *state.StateDB) error

PreProcess update state if needed from various block info used with some PoS Systems

func (*DaTong) Prepare

func (dt *DaTong) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline.

func (*DaTong) Seal

func (dt *DaTong) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

Seal generates a new sealing request for the given input block and pushes the result into the given channel.

Note, the method returns immediately and will send the result async. More than one result may also be returned depending on the consensus algorothm.

func (*DaTong) SealHash

func (dt *DaTong) SealHash(header *types.Header) (hash common.Hash)

SealHash returns the hash of a block prior to it being sealed.

func (*DaTong) SetStateCache

func (dt *DaTong) SetStateCache(stateCache state.Database)

func (*DaTong) VerifyHeader

func (dt *DaTong) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error

VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum ethash engine.

func (*DaTong) VerifyHeaders

func (dt *DaTong) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications.

func (*DaTong) VerifySeal

func (c *DaTong) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*DaTong) VerifyUncles

func (dt *DaTong) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Ethereum ethash engine.

type DisInfo

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

type DisInfoWithIndex

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

type DistanceSlice

type DistanceSlice []*DisInfo

func (DistanceSlice) Len

func (s DistanceSlice) Len() int

func (DistanceSlice) Less

func (s DistanceSlice) Less(i, j int) bool

func (DistanceSlice) Swap

func (s DistanceSlice) Swap(i, j int)

type SignerFn

type SignerFn func(accounts.Account, []byte) ([]byte, error)

SignerFn is a signer callback function to request a hash to be signed by a backing account.

type Snapshot

type Snapshot struct {
	Selected     common.Hash   `json:"selected"`
	Retreat      []common.Hash `json:"retreat"`
	TicketNumber int           `json:"ticketNumber"`
}

Snapshot wacom

func NewSnapshotFromHeader

func NewSnapshotFromHeader(header *types.Header) (*Snapshot, error)

NewSnapshotFromHeader wacom

Jump to

Keyboard shortcuts

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