Documentation
¶
Index ¶
- Constants
- Variables
- func Max(x, y int64) int64
- func Min(x, y int64) int64
- type IPos
- func (c *IPos) APIs(chain consensus.ChainReader) []rpc.API
- func (c *IPos) Author(header *types.Header) (common.Address, error)
- func (c *IPos) Authorize(signer common.Address, signFn SignerFn)
- func (c *IPos) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (c *IPos) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (c *IPos) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (c *IPos) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (c *IPos) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (c *IPos) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (c *IPos) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type SignerFn
Constants ¶
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
)
const (
IPOSContractAddress = "0x0000000000000000000000000000000000000100"
)
const MAX_BALANCE_IONC int64 = 800000000 // IONC 8亿
const TARGET = BLOCK_TIME * MAX_BALANCE_IONC
Variables ¶
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 ¶
Types ¶
type IPos ¶
type IPos struct {
IpcEndpoint string
// contains filtered or unexported fields
}
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements. 校验是否符合共识规则(nonce,签名)
func (*IPos) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock ionchain ethash engine.