-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract common types from sync (#7843)
* extract common types from sync * fix tests * simplify Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
- Loading branch information
1 parent
fec4692
commit 7735a08
Showing
17 changed files
with
163 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package types | ||
|
||
import "errors" | ||
|
||
var ( | ||
ErrWrongForkDigestVersion = errors.New("wrong fork digest version") | ||
ErrInvalidEpoch = errors.New("invalid epoch") | ||
ErrInvalidFinalizedRoot = errors.New("invalid finalized root") | ||
ErrInvalidSequenceNum = errors.New("invalid sequence number provided") | ||
ErrGeneric = errors.New("internal service error") | ||
ErrInvalidParent = errors.New("mismatched parent root") | ||
ErrRateLimited = errors.New("rate limited") | ||
ErrIODeadline = errors.New("i/o deadline exceeded") | ||
ErrInvalidRequest = errors.New("invalid range, step or count") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package types | ||
|
||
// RPCGoodbyeCode represents goodbye code, used in sync package. | ||
type RPCGoodbyeCode = SSZUint64 | ||
|
||
const ( | ||
// Spec defined codes. | ||
GoodbyeCodeClientShutdown RPCGoodbyeCode = iota | ||
GoodbyeCodeWrongNetwork | ||
GoodbyeCodeGenericError | ||
|
||
// Teku specific codes | ||
GoodbyeCodeUnableToVerifyNetwork = RPCGoodbyeCode(128) | ||
|
||
// Lighthouse specific codes | ||
GoodbyeCodeTooManyPeers = RPCGoodbyeCode(129) | ||
GoodbyeCodeBadScore = RPCGoodbyeCode(250) | ||
GoodbyeCodeBanned = RPCGoodbyeCode(251) | ||
) | ||
|
||
// GoodbyeCodeMessages defines a mapping between goodbye codes and string messages. | ||
var GoodbyeCodeMessages = map[RPCGoodbyeCode]string{ | ||
GoodbyeCodeClientShutdown: "client shutdown", | ||
GoodbyeCodeWrongNetwork: "irrelevant network", | ||
GoodbyeCodeGenericError: "fault/error", | ||
GoodbyeCodeUnableToVerifyNetwork: "unable to verify network", | ||
GoodbyeCodeTooManyPeers: "client has too many peers", | ||
GoodbyeCodeBadScore: "peer score too low", | ||
GoodbyeCodeBanned: "client banned this node", | ||
} | ||
|
||
// ErrToGoodbyeCode converts given error to RPC goodbye code. | ||
func ErrToGoodbyeCode(err error) RPCGoodbyeCode { | ||
switch err { | ||
case ErrWrongForkDigestVersion: | ||
return GoodbyeCodeWrongNetwork | ||
default: | ||
return GoodbyeCodeGenericError | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.