mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-03-05 00:28:51 +00:00
[NOD-1525] Implement headers first ibd (#1017)
* [NOD-1525] Implement headers first IBD * [NOD-1525] Fix proto translators * [NOD-1525] Register missing flows * [NOD-1525] Rename SyncStateNormal->SyncStateRelay, simplifiy IBD peer selection code and get rid of panic in FinishIBD * [NOD-1525] Remove redundant methods from interface
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package protocolerrors
|
||||
|
||||
import "github.com/pkg/errors"
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus/ruleerrors"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ProtocolError is an error that signifies a violation
|
||||
// of the peer-to-peer protocol
|
||||
@@ -50,3 +53,14 @@ func Wrapf(shouldBan bool, err error, format string, args ...interface{}) error
|
||||
Cause: errors.Wrapf(err, format, args...),
|
||||
}
|
||||
}
|
||||
|
||||
// ConvertToBanningProtocolErrorIfRuleError converts the given error to
|
||||
// a banning protocol error if it's a rule error, and otherwise keep it
|
||||
// as is.
|
||||
func ConvertToBanningProtocolErrorIfRuleError(err error, format string, args ...interface{}) error {
|
||||
if !errors.As(err, &ruleerrors.RuleError{}) {
|
||||
return err
|
||||
}
|
||||
|
||||
return Wrapf(true, err, format, args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user