Go-ethereum 源碼解析之 go-ethereum/consensus/errors.go
Source code
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum 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 go-ethereum 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 go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package consensus
import "errors"
var (
// ErrUnknownAncestor is returned when validating a block requires an ancestor
// that is unknown.
ErrUnknownAncestor = errors.New("unknown ancestor")
// ErrPrunedAncestor is returned when validating a block requires an ancestor
// that is known, but the state of which is not available.
ErrPrunedAncestor = errors.New("pruned ancestor")
// ErrFutureBlock is returned when a block's timestamp is in the future according
// to the current node.
ErrFutureBlock = errors.New("block in the future")
// ErrInvalidNumber is returned if a block's number doesn't equal it's parent's
// plus one.
ErrInvalidNumber = errors.New("invalid block number")
)
Appendix A. 總體批注
本文件中定義了包 consensus 中的通用錯誤嘲碱。對于特定的共識引擎 Clique 和 Ethash阴颖,其子包中將定義特定共識引擎內(nèi)部使用的錯誤朝扼。
Appendix B. 詳細(xì)批注
1. var
- ErrUnknownAncestor = errors.New("unknown ancestor"):當(dāng)驗證區(qū)塊需要的一個祖先區(qū)塊未知時返回 ErrUnknownAncestor。
- ErrPrunedAncestor = errors.New("pruned ancestor"):當(dāng)驗證區(qū)塊需要的一個祖先區(qū)塊已知但狀態(tài)不可用時返回 ErrPrunedAncestor丑瞧。
- ErrFutureBlock = errors.New("block in the future"):對于本地節(jié)點,如果區(qū)塊的時間戳在當(dāng)前時間戳之后蜀肘,將返回 ErrFutureBlock绊汹。
- ErrInvalidNumber = errors.New("invalid block number"):如果區(qū)塊的編號不等于它的父區(qū)塊的編號加 1,則返回 ErrInvalidNumber扮宠。
Reference
Contributor
- Windstamp, https://github.com/windstamp