Documentation
¶
Overview ¶
* Copyright (C) 2021 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2021 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func CalcBaseFee(parent *Header) *big.Int
- func GetCurrentHeaderHeight(native *native.NativeService, chainID uint64) (uint64, error)
- func HashHeader(header *Header) (hash ethcommon.Hash)
- func IsHeaderExist(native *native.NativeService, hash []byte, chainID uint64) (bool, error)
- func RestructChain(native *native.NativeService, current, new *Header, chainID uint64) error
- func VerifyEip1559Header(parent, header *Header) error
- func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error
- type Caches
- type ETHHandler
- type Header
- func GetCurrentHeader(native *native.NativeService, chainID uint64) (*Header, *big.Int, error)
- func GetHeaderByHash(native *native.NativeService, hash []byte, chainID uint64) (*Header, *big.Int, error)
- func GetHeaderByHeight(native *native.NativeService, height, chainID uint64) (*Header, *big.Int, error)
- func To1559(h *types.Header) *Header
- type HeaderWithDifficultySum
- type KeccakState
Constants ¶
const ( BaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks. ElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have. InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks. )
Variables ¶
Functions ¶
func CalcBaseFee ¶ added in v1.6.0
CalcBaseFee calculates the basefee of the header.
func GetCurrentHeaderHeight ¶
func GetCurrentHeaderHeight(native *native.NativeService, chainID uint64) (uint64, error)
func HashHeader ¶
func IsHeaderExist ¶
func RestructChain ¶
func RestructChain(native *native.NativeService, current, new *Header, chainID uint64) error
func VerifyEip1559Header ¶ added in v1.6.0
VerifyEip1559Header verifies some header attributes which were changed in EIP-1559, - gas limit check - basefee check
func VerifyGaslimit ¶ added in v1.6.0
VerifyGaslimit verifies the header gas limit according increase/decrease in relation to the parent gas limit.
Types ¶
type ETHHandler ¶
type ETHHandler struct { }
func NewETHHandler ¶
func NewETHHandler() *ETHHandler
func (*ETHHandler) SyncBlockHeader ¶
func (this *ETHHandler) SyncBlockHeader(native *native.NativeService) error
func (*ETHHandler) SyncCrossChainMsg ¶
func (this *ETHHandler) SyncCrossChainMsg(native *native.NativeService) error
func (*ETHHandler) SyncGenesisHeader ¶
func (this *ETHHandler) SyncGenesisHeader(native *native.NativeService) error
type Header ¶ added in v1.6.0
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"` }
func GetCurrentHeader ¶
func GetHeaderByHash ¶
func GetHeaderByHeight ¶
func (Header) MarshalJSON ¶ added in v1.6.0
MarshalJSON marshals as JSON.
func (*Header) UnmarshalJSON ¶ added in v1.6.0
UnmarshalJSON unmarshals from JSON.
type HeaderWithDifficultySum ¶
type KeccakState ¶ added in v1.6.0
KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.