-
Notifications
You must be signed in to change notification settings - Fork 10
/
errors.go
48 lines (38 loc) · 1.39 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2020 The Meter.io developers
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html>
package consensus
import (
"errors"
)
var (
errFutureBlock = errors.New("block in the future")
errParentMissing = errors.New("parent block is missing")
errQCNodeMissing = errors.New("qcNode is missing")
errKnownBlock = errors.New("block already in the chain")
errParentHeaderMissing = errors.New("parent header is missing")
errDecodeParentFailed = errors.New("decode parent failed")
errRestartPaceMakerRequired = errors.New("restart pacemaker required")
)
type consensusError string
func (err consensusError) Error() string {
return string(err)
}
// IsFutureBlock returns if the error indicates that the block should be
// processed later.
func IsFutureBlock(err error) bool {
return err == errFutureBlock
}
// IsParentMissing ...
func IsParentMissing(err error) bool {
return err == errParentMissing
}
// IsKnownBlock returns if the error means the block was already in the chain.
func IsKnownBlock(err error) bool {
return err == errKnownBlock
}
// IsCritical returns if the error is consensus related.
func IsCritical(err error) bool {
_, ok := err.(consensusError)
return ok
}