Go-ethereum 源碼解析之 go-ethereum/consensus/errors.go

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. 詳細批注

1. var

  • ErrUnknownAncestor = errors.New("unknown ancestor"):當驗證區(qū)塊需要的一個祖先區(qū)塊未知時返回 ErrUnknownAncestor。
  • ErrPrunedAncestor = errors.New("pruned ancestor"):當驗證區(qū)塊需要的一個祖先區(qū)塊已知但狀態(tài)不可用時返回 ErrPrunedAncestor。
  • ErrFutureBlock = errors.New("block in the future"):對于本地節(jié)點,如果區(qū)塊的時間戳在當前時間戳之后,將返回 ErrFutureBlock。
  • ErrInvalidNumber = errors.New("invalid block number"):如果區(qū)塊的編號不等于它的父區(qū)塊的編號加 1,則返回 ErrInvalidNumber。

Reference

  1. https://github.com/ethereum/go-ethereum/blob/master/consensus/errors.go

Contributor

  1. Windstamp, https://github.com/windstamp
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容