-
Notifications
You must be signed in to change notification settings - Fork 175
/
errors.go
98 lines (77 loc) · 2.44 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package model
import (
"errors"
"fmt"
"github.com/onflow/flow-go/model/flow"
)
// NoVoteError contains the reason of why the voter didn't vote for a block proposal.
type NoVoteError struct {
Msg string
}
func (e NoVoteError) Error() string { return e.Msg }
// IsNoVoteError returns whether an error is NoVoteError
func IsNoVoteError(err error) bool {
var e NoVoteError
return errors.As(err, &e)
}
var ErrUnverifiableBlock = errors.New("block proposal can't be verified, because its view is above the finalized view, but its QC is below the finalized view")
var ErrInvalidSigner = errors.New("invalid signer(s)")
var ErrInvalidSignature = errors.New("invalid signature")
type ConfigurationError struct {
Msg string
}
func (e ConfigurationError) Error() string { return e.Msg }
type MissingBlockError struct {
View uint64
BlockID flow.Identifier
}
func (e MissingBlockError) Error() string {
return fmt.Sprintf("missing Block at view %d with ID %v", e.View, e.BlockID)
}
// IsMissingBlockError returns whether an error is MissingBlockError
func IsMissingBlockError(err error) bool {
var e MissingBlockError
return errors.As(err, &e)
}
type InvalidBlockError struct {
BlockID flow.Identifier
View uint64
Err error
}
func (e InvalidBlockError) Error() string {
return fmt.Sprintf("invalid block %x at view %d: %s", e.BlockID, e.View, e.Err.Error())
}
// IsInvalidBlockError returns whether an error is InvalidBlockError
func IsInvalidBlockError(err error) bool {
var e InvalidBlockError
return errors.As(err, &e)
}
func (e InvalidBlockError) Unwrap() error {
return e.Err
}
type InvalidVoteError struct {
VoteID flow.Identifier
View uint64
Err error
}
func (e InvalidVoteError) Error() string {
return fmt.Sprintf("invalid vote %x for view %d: %s", e.VoteID, e.View, e.Err.Error())
}
// IsInvalidVoteError returns whether an error is InvalidVoteError
func IsInvalidVoteError(err error) bool {
var e InvalidVoteError
return errors.As(err, &e)
}
func (e InvalidVoteError) Unwrap() error {
return e.Err
}
// ByzantineThresholdExceededError is raised if HotStuff detects malicious conditions which
// prove a Byzantine threshold of consensus replicas has been exceeded.
// Per definition, the byzantine threshold is exceeded is there are byzantine consensus
// replicas with _at least_ 1/3 stake.
type ByzantineThresholdExceededError struct {
Evidence string
}
func (e ByzantineThresholdExceededError) Error() string {
return e.Evidence
}