ipos

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLOCK_TIME          int64 = 15
	MAX_BLOCKTIME_LIMIT int64 = BLOCK_TIME + 2
	MIN_BLOCKTIME_LIMIT int64 = BLOCK_TIME - 2
)

const (

//INITIAL_BASE_TARGET int64 = 153722867
INITIAL_BASE_TARGET int64 = 180143985
MAX_BALANCE_NXT     int64 = 800000000 // IONC 8亿
MAX_BASE_TARGET     int64 = MAX_BALANCE_NXT * INITIAL_BASE_TARGET

)

View Source
const (
	IPOSContractAddress = "0x0000000000000000000000000000000000000100"
)
View Source
const MAX_BALANCE_IONC int64 = 800000000 // IONC 8亿

Variables

View Source
var (
	INITIAL_BASE_TARGET int64 = new(big.Int).Div(math.MaxBig63, big.NewInt(TARGET)).Int64()
	MAX_BASE_TARGET     int64 = INITIAL_BASE_TARGET * MAX_BALANCE_IONC // main 50  ,test MAX_BALANCE_IONC
	MIN_BASE_TARGET     int64 = INITIAL_BASE_TARGET * 9 / 10
	BASE_TARGET_GAMMA   int64 = 64

	DIFFICULTY_MULTIPLIER = new(big.Int).Mul(math.MaxBig64, big.NewInt(60))
)

Functions

func Max

func Max(x, y int64) int64

func Min

func Min(x, y int64) int64

Types

type IPos

type IPos struct {
	IpcEndpoint string
	// contains filtered or unexported fields
}

func New

func New(db ioncdb.Database, IpcEndpoint string) *IPos

func (*IPos) APIs

func (c *IPos) APIs(chain consensus.ChainReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.

func (*IPos) Author

func (c *IPos) Author(header *types.Header) (common.Address, error)

Author retrieves the ionchain 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 (*IPos) Authorize

func (c *IPos) Authorize(signer common.Address, signFn SignerFn)

Authorize injects a private key into the consensus engine to mint new blocks with.

func (*IPos) Finalize

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

Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block. 返回最终的区块

func (*IPos) Prepare

func (c *IPos) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top. 返回共识所需要的区块头,baseTarget

func (*IPos) Seal

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

Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials. 尝试补全区块(nonce,签名) 判断是否有出块权

func (*IPos) VerifyHeader

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

VerifyHeader checks whether a header conforms to the consensus rules. 校验区块头 检查是否符合共识

func (*IPos) VerifyHeaders

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

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice). 与VerifyHeader类似,批量校验区块头,返回 quit channel 用来取消操作,results channel 异步取出结果

func (*IPos) VerifySeal

func (c *IPos) 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. 校验是否符合共识规则(nonce,签名)

func (*IPos) VerifyUncles

func (c *IPos) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

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

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.

Jump to

Keyboard shortcuts

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