代码拉取完成,页面将自动刷新
// Copyright 2018 The aqchain-blockchain Authors
// This file is part of the aqchain-blockchain library.
//
// The aqchain-blockchain library 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 aqchain-blockchain library 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 aqchain-blockchain library. If not, see <http://www.gnu.org/licenses/>.
// Package poc implements the delegated-proof-of-stake consensus engine.
package poc
import (
"gitee.com/aqchain/go-ethereum/common"
"gitee.com/aqchain/go-ethereum/consensus"
"gitee.com/aqchain/go-ethereum/core/types"
"gitee.com/aqchain/go-ethereum/rpc"
)
// API is a user facing RPC API to allow controlling the signer and voting
// mechanisms of the delegated-proof-of-stake scheme.
type API struct {
chain consensus.ChainReader
poc *PoC
}
// GetSnapshot retrieves the state snapshot at a given block.
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) {
// Retrieve the requested block number (or current if none requested)
var header *types.Header
if number == nil || *number == rpc.LatestBlockNumber {
header = api.chain.CurrentHeader()
} else {
header = api.chain.GetHeaderByNumber(uint64(number.Int64()))
}
// Ensure we have an actually valid block and return its snapshot
if header == nil {
return nil, errUnknownBlock
}
return api.poc.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil, defaultLoopCntRecalculateSigners)
}
// GetSnapshotAtHash retrieves the state snapshot at a given block.
func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) {
header := api.chain.GetHeaderByHash(hash)
if header == nil {
return nil, errUnknownBlock
}
return api.poc.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil, defaultLoopCntRecalculateSigners)
}
// GetSnapshotAtNumber retrieves the state snapshot at a given block.
func (api *API) GetSnapshotAtNumber(number uint64) (*Snapshot, error) {
header := api.chain.GetHeaderByNumber(number)
if header == nil {
return nil, errUnknownBlock
}
return api.poc.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil, defaultLoopCntRecalculateSigners)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。