Documentation ¶
Index ¶
- Constants
- Variables
- func AdminAddr() common.Address
- func CirculatesAddr() common.Address
- func DaemonNodeAddress() common.Address
- func GuardAddress() []common.Address
- func InitBlockSyncer(chain *FullBlockChain)
- func InitCore(helper types.ConsensusHelper, account types.Account) error
- func IsInExtractGuardNodes(addr common.Address) bool
- func NewFundGuardNode() *fundGuardNode
- func NewRewardManager() *rewardManager
- func StakePlatformAddr() common.Address
- func UserNodeAddress() common.Address
- type AddressManager
- type BaseMiner
- type BlockChainConfig
- type BlockProvider
- type FullBlockChain
- func (chain *FullBlockChain) AccountDBAt(height uint64) (types.AccountDB, error)
- func (chain *FullBlockChain) AddBlockOnChain(source string, b *types.Block) types.AddBlockResult
- func (chain *FullBlockChain) AddChainSlice(source string, chainSlice []*types.Block, cb batchAddBlockCallback)
- func (chain *FullBlockChain) AddTransactionToPool(tx *types.Transaction) (bool, error)
- func (chain *FullBlockChain) BatchGetBlockHeadersBetween(begin, end uint64) []*types.BlockHeader
- func (chain *FullBlockChain) BatchGetBlocksAfterHeight(height uint64, limit int) []*types.Block
- func (chain *FullBlockChain) BatchGetBlocksBetween(begin, end uint64) []*types.Block
- func (chain *FullBlockChain) CastBlock(height uint64, proveValue []byte, qn uint64, castor []byte, gSeed common.Hash) *types.Block
- func (chain *FullBlockChain) CheckPointAt(h uint64) *types.BlockHeader
- func (chain *FullBlockChain) Clear() error
- func (chain *FullBlockChain) Close()
- func (chain *FullBlockChain) CountBlocksInRange(startHeight uint64, endHeight uint64) uint64
- func (chain *FullBlockChain) DeleteSmallDbByHeight(heightLimit uint64) error
- func (chain *FullBlockChain) GetAccountDBByHash(hash common.Hash) (types.AccountDB, error)
- func (chain *FullBlockChain) GetBalance(address common.Address) *big.Int
- func (chain *FullBlockChain) GetConsensusHelper() types.ConsensusHelper
- func (chain *FullBlockChain) GetNonce(address common.Address) uint64
- func (chain *FullBlockChain) GetRewardManager() types.RewardManager
- func (chain *FullBlockChain) GetTransactionByHash(onlyReward bool, h common.Hash) *types.Transaction
- func (chain *FullBlockChain) GetTransactionPool() types.TransactionPool
- func (chain *FullBlockChain) HasBlock(hash common.Hash) bool
- func (chain *FullBlockChain) HasHeight(height uint64) bool
- func (chain *FullBlockChain) Height() uint64
- func (chain *FullBlockChain) IsAdjusting() bool
- func (chain *FullBlockChain) IsPruneMode() bool
- func (chain *FullBlockChain) IsSyncing() bool
- func (chain *FullBlockChain) LatestAccountDB() (types.AccountDB, error)
- func (chain *FullBlockChain) LatestCheckPoint() *types.BlockHeader
- func (chain *FullBlockChain) LogDbStats()
- func (chain *FullBlockChain) PersistentState()
- func (chain *FullBlockChain) QueryBlockByHash(hash common.Hash) *types.Block
- func (chain *FullBlockChain) QueryBlockByHeight(height uint64) *types.Block
- func (chain *FullBlockChain) QueryBlockCeil(height uint64) *types.Block
- func (chain *FullBlockChain) QueryBlockFloor(height uint64) *types.Block
- func (chain *FullBlockChain) QueryBlockHeaderByHash(hash common.Hash) *types.BlockHeader
- func (chain *FullBlockChain) QueryBlockHeaderByHeight(height uint64) *types.BlockHeader
- func (chain *FullBlockChain) QueryBlockHeaderCeil(height uint64) *types.BlockHeader
- func (chain *FullBlockChain) QueryBlockHeaderFloor(height uint64) *types.BlockHeader
- func (chain *FullBlockChain) QueryTopBlock() *types.BlockHeader
- func (chain *FullBlockChain) Remove(block *types.Block) bool
- func (chain *FullBlockChain) ResetNear(bh *types.BlockHeader) (restartBh *types.BlockHeader, err error)
- func (chain *FullBlockChain) ResetTop(bh *types.BlockHeader) error
- func (chain *FullBlockChain) ScanBlockHeightsInRange(startHeight uint64, endHeight uint64) []uint64
- func (chain *FullBlockChain) TotalQN() uint64
- func (chain *FullBlockChain) Traverse(height uint64, config *account.TraverseConfig) (bool, error)
- func (chain *FullBlockChain) Version() int
- type FundGuardType
- type GuardProposalMiner
- type InvalidProposalMiner
- type MessageBase
- type MinerManager
- func (mm *MinerManager) ClearTicker()
- func (mm *MinerManager) ExecuteOperation(accountDB types.AccountDB, msg types.TxMessage, height uint64) (success bool, err error)
- func (mm *MinerManager) FullStakeGuardNodesCheck(db types.AccountDB, height uint64) ([]common.Address, error)
- func (mm *MinerManager) FundGuardExpiredCheck(accountDB types.AccountDB, height uint64) ([]common.Address, error)
- func (mm *MinerManager) GetAllFullStakeGuardNodes(accountDB types.AccountDB) []common.Address
- func (mm *MinerManager) GetAllFundStakeGuardNodes(accountDB types.AccountDB) ([]*fundGuardNodeDetail, error)
- func (mm *MinerManager) GetAllGuardNodeAddrs(accountDB types.AccountDB) ([]common.Address, error)
- func (mm *MinerManager) GetAllMiners(mType types.MinerType, height uint64) []*types.Miner
- func (mm *MinerManager) GetAllStakeDetails(address common.Address) map[string][]*types.StakeDetail
- func (mm *MinerManager) GetFullMinerPoolStake(height uint64) uint64
- func (mm *MinerManager) GetFundGuard(addr string) (*fundGuardNode, error)
- func (mm *MinerManager) GetLatestMiner(address common.Address, mType types.MinerType) *types.Miner
- func (mm *MinerManager) GetMiner(address common.Address, mType types.MinerType, height uint64) *types.Miner
- func (mm *MinerManager) GetProposalTotalStake(height uint64) uint64
- func (mm *MinerManager) GetStakeDetails(address common.Address, source common.Address) []*types.StakeDetail
- func (mm *MinerManager) GetTickets(db types.AccountDB, address common.Address) uint64
- func (mm *MinerManager) GetValidTicketsByHeight(height uint64) uint64
- func (mm *MinerManager) GuardNodesCheck(accountDB types.AccountDB, bh *types.BlockHeader)
- func (mm *MinerManager) MinerFrozen(accountDB types.AccountDB, miner common.Address, height uint64) (success bool, err error)
- func (mm *MinerManager) MinerPenalty(accountDB types.AccountDB, penalty types.PunishmentMsg, height uint64) (success bool, err error)
- func (mm *MinerManager) ValidateStakeAdd(tx *types.Transaction) error
- type MinerPoolProposalMiner
- type NormalProposalMiner
- type OfflineTailor
- type PruneConfig
- type Replayer
- type SyncCandidateInfo
- type TransactionWithTime
- type UnSupportMiner
- type VerifyMiner
Constants ¶
const ( MinMinerStake = 500 * common.ZVC // minimal token of miner can stake MaxMinerStakeAdjustPeriod = 10000000 // maximal token of miner can stake )
const ( TransactionGasCost uint64 = 400 CodeBytePrice = 19073 //1.9073486328125 CodeBytePricePrecision = 10000 MaxCastBlockTime = time.Second * 2 )
const AddressContract = "zv0000000000000000000000000000000000000000000000000000000000000006"
const AddressSource = "zv0007"
address manager contract creator
const (
GasLimitPerBlock = 2000000 // the max gas limit for a block
)
const TriesInMemory uint64 = types.EpochLength*4 + 20
Variables ¶
var ( ErrorBlockHash = errors.New("consensus verify fail,block hash error") ErrorGroupSign = errors.New("consensus verify fail,group sign signature error") ErrorRandomSign = errors.New("consensus verify fail,random signature error") ErrPkNotExists = errors.New("consensus verify fail,pk not exists") ErrPkNil = errors.New("pk is nil") ErrGroupNotExists = errors.New("group not exists") )
var ( ErrBlockExist = errors.New("block exist") ErrPreNotExist = errors.New("pre block not exist") ErrLocalMoreWeight = errors.New("local more weight") ErrCommitBlockFail = errors.New("commit block fail") ErrBlockSizeLimit = errors.New("block size exceed the limit") )
var ( ProposerPackageTime = MaxCastBlockTime GasLimitForPackage = uint64(GasLimitPerBlock) IgnoreVmCall = false )
var ( ErrNil = errors.New("nil transaction") ErrHash = errors.New("invalid transaction hash") ErrGasPrice = errors.New("gas price is too low") ErrSign = errors.New("sign error") ErrNonce = errors.New("nonce error") ErrDataSizeTooLong = errors.New("data size too long") )
var GroupManagerImpl *group.Manager
var Logger *logrus.Logger
var TxSyncer *txSyncer
Functions ¶
func CirculatesAddr ¶ added in v1.0.11
func DaemonNodeAddress ¶ added in v1.0.11
func GuardAddress ¶ added in v1.0.11
func InitBlockSyncer ¶
func InitBlockSyncer(chain *FullBlockChain)
InitBlockSyncer initialize the blockSyncer. Register the ticker for sending and requesting blocks to neighbors timely and also subscribe these events to handle requests from neighbors
func InitCore ¶
func InitCore(helper types.ConsensusHelper, account types.Account) error
InitCore initialize the peerManagerImpl, BlockChainImpl and GroupChainImpl
func IsInExtractGuardNodes ¶ added in v1.0.11
func NewFundGuardNode ¶
func NewFundGuardNode() *fundGuardNode
func NewRewardManager ¶
func NewRewardManager() *rewardManager
func StakePlatformAddr ¶ added in v1.0.11
func UserNodeAddress ¶ added in v1.0.11
Types ¶
type AddressManager ¶ added in v1.0.11
type AddressManager struct { }
func (*AddressManager) DeployAddressManagerContract ¶ added in v1.0.11
func (am *AddressManager) DeployAddressManagerContract(stateDB *account.AccountDB)
type BlockChainConfig ¶
type BlockChainConfig struct {
// contains filtered or unexported fields
}
BlockChainConfig contains the configuration values of leveldb prefix string
type BlockProvider ¶
BlockProvider provides blocks of the given height range [start, end)
func NewLocalBlockProvider ¶
func NewLocalBlockProvider(dir string) (BlockProvider, error)
type FullBlockChain ¶
FullBlockChain manages chain imports, reverts, chain reorganisations.
var BlockChainImpl *FullBlockChain
func (*FullBlockChain) AccountDBAt ¶
func (chain *FullBlockChain) AccountDBAt(height uint64) (types.AccountDB, error)
AccountDBAt returns account database with specified block height
func (*FullBlockChain) AddBlockOnChain ¶
func (chain *FullBlockChain) AddBlockOnChain(source string, b *types.Block) types.AddBlockResult
AddBlockOnChain add a block on blockchain, there are five cases of return value:
0, successfully add block on blockchain -1, verification failed 1, the block already exist on the blockchain, then we should discard it 2, the same height block with a larger QN value on the chain, then we should discard it 3, need adjust the blockchain, there will be a fork
func (*FullBlockChain) AddChainSlice ¶
func (chain *FullBlockChain) AddChainSlice(source string, chainSlice []*types.Block, cb batchAddBlockCallback)
func (*FullBlockChain) AddTransactionToPool ¶
func (chain *FullBlockChain) AddTransactionToPool(tx *types.Transaction) (bool, error)
Version of chain Id
func (*FullBlockChain) BatchGetBlockHeadersBetween ¶
func (chain *FullBlockChain) BatchGetBlockHeadersBetween(begin, end uint64) []*types.BlockHeader
BatchGetBlockHeadersBetween query blocks of the height range [start, end)
func (*FullBlockChain) BatchGetBlocksAfterHeight ¶
func (chain *FullBlockChain) BatchGetBlocksAfterHeight(height uint64, limit int) []*types.Block
BatchGetBlocksAfterHeight query blocks after the specified height
func (*FullBlockChain) BatchGetBlocksBetween ¶
func (chain *FullBlockChain) BatchGetBlocksBetween(begin, end uint64) []*types.Block
BatchGetBlocksBetween query blocks of the height range [start, end)
func (*FullBlockChain) CastBlock ¶
func (chain *FullBlockChain) CastBlock(height uint64, proveValue []byte, qn uint64, castor []byte, gSeed common.Hash) *types.Block
CastBlock cast a block, current casters synchronization operation in the group
func (*FullBlockChain) CheckPointAt ¶
func (chain *FullBlockChain) CheckPointAt(h uint64) *types.BlockHeader
func (*FullBlockChain) Clear ¶
func (chain *FullBlockChain) Clear() error
Clear clear blockchain all data. Not used now, should remove it latter
func (*FullBlockChain) CountBlocksInRange ¶
func (chain *FullBlockChain) CountBlocksInRange(startHeight uint64, endHeight uint64) uint64
CountBlocksInRange returns the count of block in a range of block height. the block with startHeight and endHeight will be included
func (*FullBlockChain) DeleteSmallDbByHeight ¶
func (chain *FullBlockChain) DeleteSmallDbByHeight(heightLimit uint64) error
from last delete small db height to current height's data can be deleted
func (*FullBlockChain) GetAccountDBByHash ¶
GetAccountDBByHash returns account database with specified block hash
func (*FullBlockChain) GetBalance ¶
func (chain *FullBlockChain) GetBalance(address common.Address) *big.Int
GetBalance return the balance of specified address
func (*FullBlockChain) GetConsensusHelper ¶
func (chain *FullBlockChain) GetConsensusHelper() types.ConsensusHelper
GetConsensusHelper returns consensus helper reference
func (*FullBlockChain) GetNonce ¶
func (chain *FullBlockChain) GetNonce(address common.Address) uint64
GetBalance returns the nonce of specified address
func (*FullBlockChain) GetRewardManager ¶
func (chain *FullBlockChain) GetRewardManager() types.RewardManager
GetRewardManager returns the reward manager
func (*FullBlockChain) GetTransactionByHash ¶
func (chain *FullBlockChain) GetTransactionByHash(onlyReward bool, h common.Hash) *types.Transaction
GetTransactionByHash get a transaction by hash
func (*FullBlockChain) GetTransactionPool ¶
func (chain *FullBlockChain) GetTransactionPool() types.TransactionPool
GetTransactionPool return the transaction pool waiting for the block
func (*FullBlockChain) HasBlock ¶
func (chain *FullBlockChain) HasBlock(hash common.Hash) bool
HasBlock returns whether the chain has a block with specific hash
func (*FullBlockChain) HasHeight ¶
func (chain *FullBlockChain) HasHeight(height uint64) bool
HasBlock returns whether the chain has a block with specific height
func (*FullBlockChain) IsAdjusting ¶
func (chain *FullBlockChain) IsAdjusting() bool
IsAdjusting means whether need to adjust blockchain, which means there may be a fork
func (*FullBlockChain) IsPruneMode ¶
func (chain *FullBlockChain) IsPruneMode() bool
func (*FullBlockChain) IsSyncing ¶
func (chain *FullBlockChain) IsSyncing() bool
func (*FullBlockChain) LatestAccountDB ¶
func (chain *FullBlockChain) LatestAccountDB() (types.AccountDB, error)
LatestAccountDB returns chain's last account database
func (*FullBlockChain) LatestCheckPoint ¶
func (chain *FullBlockChain) LatestCheckPoint() *types.BlockHeader
func (*FullBlockChain) LogDbStats ¶
func (chain *FullBlockChain) LogDbStats()
func (*FullBlockChain) PersistentState ¶
func (chain *FullBlockChain) PersistentState()
PersistentState when shut down it will be run Take last prune height's next height block state to commit big db
func (*FullBlockChain) QueryBlockByHash ¶
func (chain *FullBlockChain) QueryBlockByHash(hash common.Hash) *types.Block
QueryBlockByHash query the block by block hash
func (*FullBlockChain) QueryBlockByHeight ¶
func (chain *FullBlockChain) QueryBlockByHeight(height uint64) *types.Block
QueryBlockByHeight query the block by height
func (*FullBlockChain) QueryBlockCeil ¶
func (chain *FullBlockChain) QueryBlockCeil(height uint64) *types.Block
QueryBlockCeil query first block whose height >= height
func (*FullBlockChain) QueryBlockFloor ¶
func (chain *FullBlockChain) QueryBlockFloor(height uint64) *types.Block
QueryBlockFloor query first block whose height <= height
func (*FullBlockChain) QueryBlockHeaderByHash ¶
func (chain *FullBlockChain) QueryBlockHeaderByHash(hash common.Hash) *types.BlockHeader
QueryBlockHeaderByHash query block header according to the specified hash
func (*FullBlockChain) QueryBlockHeaderByHeight ¶
func (chain *FullBlockChain) QueryBlockHeaderByHeight(height uint64) *types.BlockHeader
QueryBlockHeaderByHeight returns the block header query by height, first query LRU, if there's not exist, then query db
func (*FullBlockChain) QueryBlockHeaderCeil ¶
func (chain *FullBlockChain) QueryBlockHeaderCeil(height uint64) *types.BlockHeader
QueryBlockHeaderCeil query first block header whose height >= height
func (*FullBlockChain) QueryBlockHeaderFloor ¶
func (chain *FullBlockChain) QueryBlockHeaderFloor(height uint64) *types.BlockHeader
QueryBlockHeaderFloor query first block header whose height <= height
func (*FullBlockChain) QueryTopBlock ¶
func (chain *FullBlockChain) QueryTopBlock() *types.BlockHeader
QueryTopBlock returns the latest block header
func (*FullBlockChain) Remove ¶
func (chain *FullBlockChain) Remove(block *types.Block) bool
Remove removes the block and blocks after it from the chain. Only used in a debug file, should be removed later
func (*FullBlockChain) ResetNear ¶
func (chain *FullBlockChain) ResetNear(bh *types.BlockHeader) (restartBh *types.BlockHeader, err error)
ResetNear reset the current top block with parameter bh,if parameter bh state not exists,then find last restart point
func (*FullBlockChain) ResetTop ¶
func (chain *FullBlockChain) ResetTop(bh *types.BlockHeader) error
ResetTop reset the current top block with parameter bh
func (*FullBlockChain) ScanBlockHeightsInRange ¶
func (chain *FullBlockChain) ScanBlockHeightsInRange(startHeight uint64, endHeight uint64) []uint64
func (*FullBlockChain) Traverse ¶
func (chain *FullBlockChain) Traverse(height uint64, config *account.TraverseConfig) (bool, error)
type FundGuardType ¶
type FundGuardType byte
type GuardProposalMiner ¶
type GuardProposalMiner struct {
*BaseMiner
}
type InvalidProposalMiner ¶
type InvalidProposalMiner struct {
*BaseMiner
}
type MessageBase ¶
type MessageBase struct { }
type MinerManager ¶
type MinerManager struct {
// contains filtered or unexported fields
}
MinerManager manage all the miner related actions
var MinerManagerImpl *MinerManager
func (*MinerManager) ClearTicker ¶
func (mm *MinerManager) ClearTicker()
ClearTicker clear the ticker routine
func (*MinerManager) ExecuteOperation ¶
func (mm *MinerManager) ExecuteOperation(accountDB types.AccountDB, msg types.TxMessage, height uint64) (success bool, err error)
ExecuteOperation execute the miner operation
func (*MinerManager) FullStakeGuardNodesCheck ¶
func (*MinerManager) FundGuardExpiredCheck ¶
func (*MinerManager) GetAllFullStakeGuardNodes ¶
func (mm *MinerManager) GetAllFullStakeGuardNodes(accountDB types.AccountDB) []common.Address
func (*MinerManager) GetAllFundStakeGuardNodes ¶
func (mm *MinerManager) GetAllFundStakeGuardNodes(accountDB types.AccountDB) ([]*fundGuardNodeDetail, error)
func (*MinerManager) GetAllGuardNodeAddrs ¶ added in v1.0.8
GetAllGuardNodeAddrs return all guard node addresses,contains fund guard addresses and full stake addresses
func (*MinerManager) GetAllMiners ¶
GetAllMiners returns all miners of the the specified type at the given height
func (*MinerManager) GetAllStakeDetails ¶
func (mm *MinerManager) GetAllStakeDetails(address common.Address) map[string][]*types.StakeDetail
GetAllStakeDetails returns all stake details of the given account
func (*MinerManager) GetFullMinerPoolStake ¶
func (mm *MinerManager) GetFullMinerPoolStake(height uint64) uint64
func (*MinerManager) GetFundGuard ¶
func (mm *MinerManager) GetFundGuard(addr string) (*fundGuardNode, error)
func (*MinerManager) GetLatestMiner ¶
GetMiner return the latest miner info stored in db of the given address and the miner type
func (*MinerManager) GetMiner ¶
func (mm *MinerManager) GetMiner(address common.Address, mType types.MinerType, height uint64) *types.Miner
GetMiner return miner info stored in db of the given address and the miner type at the given height
func (*MinerManager) GetProposalTotalStake ¶
func (mm *MinerManager) GetProposalTotalStake(height uint64) uint64
GetProposalTotalStake returns the chain's total staked value of proposals at the specific block height
func (*MinerManager) GetStakeDetails ¶
func (mm *MinerManager) GetStakeDetails(address common.Address, source common.Address) []*types.StakeDetail
GetStakeDetails returns all the stake details of the given address pairs
func (*MinerManager) GetTickets ¶
func (*MinerManager) GetValidTicketsByHeight ¶
func (mm *MinerManager) GetValidTicketsByHeight(height uint64) uint64
func (*MinerManager) GuardNodesCheck ¶
func (mm *MinerManager) GuardNodesCheck(accountDB types.AccountDB, bh *types.BlockHeader)
GuardNodesCheck check guard nodes is expired
func (*MinerManager) MinerFrozen ¶
func (mm *MinerManager) MinerFrozen(accountDB types.AccountDB, miner common.Address, height uint64) (success bool, err error)
FreezeMiner execute the miner frozen operation
func (*MinerManager) MinerPenalty ¶
func (mm *MinerManager) MinerPenalty(accountDB types.AccountDB, penalty types.PunishmentMsg, height uint64) (success bool, err error)
func (*MinerManager) ValidateStakeAdd ¶
func (mm *MinerManager) ValidateStakeAdd(tx *types.Transaction) error
type MinerPoolProposalMiner ¶
type MinerPoolProposalMiner struct {
*BaseMiner
}
type NormalProposalMiner ¶
type NormalProposalMiner struct {
*BaseMiner
}
type OfflineTailor ¶
type OfflineTailor struct {
// contains filtered or unexported fields
}
func NewOfflineTailor ¶
func (*OfflineTailor) Compaction ¶
func (t *OfflineTailor) Compaction()
func (*OfflineTailor) Pruning ¶
func (t *OfflineTailor) Pruning()
func (*OfflineTailor) Verify ¶
func (t *OfflineTailor) Verify() error
type PruneConfig ¶
type PruneConfig struct {
// contains filtered or unexported fields
}
type Replayer ¶
type Replayer interface {
Replay(provider BlockProvider, out io.Writer) error
}
func NewFastReplayer ¶
func NewFastReplayer(bp BlockProvider, chain *FullBlockChain, out io.Writer) Replayer
type SyncCandidateInfo ¶
type TransactionWithTime ¶
type TransactionWithTime struct {
// contains filtered or unexported fields
}
type UnSupportMiner ¶
type UnSupportMiner struct { }
type VerifyMiner ¶
type VerifyMiner struct {
*BaseMiner
}
Source Files ¶
- address_manager.go
- address_manager_contract.go
- block_sync.go
- block_util.go
- blockchain.go
- blockchain_action.go
- blockchain_enhance.go
- blockchain_msg.go
- blockchain_reader.go
- blockchain_store.go
- check_point_access.go
- checkpoint.go
- doc.go
- fork_processor.go
- foundation_contract.go
- govern.go
- init.go
- message.go
- miner_base.go
- miner_cache_store.go
- miner_manager.go
- miner_node.go
- miner_operation.go
- peers_meter.go
- rewards_manager.go
- simple_container.go
- stake_query.go
- state_processor.go
- state_prune.go
- transaction_pool.go
- transaction_store.go
- trie_small_db_store.go
- tx_batch.go
- tx_codec.go
- tx_reward_pool.go
- tx_sync.go
- tx_validate.go