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,其子包中将定义特定共识引擎内部使用的错误。

Appendix B. 详细批注

1. var

  • ErrUnknownAncestor = errors.New("unknown ancestor"):当验证区块需要的一个祖先区块未知时返回 ErrUnknownAncestor。
  • ErrPrunedAncestor = errors.New("pruned ancestor"):当验证区块需要的一个祖先区块已知但状态不可用时返回 ErrPrunedAncestor。
  • ErrFutureBlock = errors.New("block in the future"):对于本地节点,如果区块的时间戳在当前时间戳之后,将返回 ErrFutureBlock。
  • ErrInvalidNumber = errors.New("invalid block number"):如果区块的编号不等于它的父区块的编号加 1,则返回 ErrInvalidNumber。

Reference

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

Contributor

  1. Windstamp, https://github.com/windstamp
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容