[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:
Ori Newman
2020-11-10 06:14:51 -08:00
committed by GitHub
parent 31c5264430
commit 23c1ea6c31
51 changed files with 2822 additions and 1802 deletions

View File

@@ -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...)
}