[NOD-839] Panic from non-rule error from ProcessBlock (#660)

This commit is contained in:
Ori Newman 2020-03-15 17:26:53 +02:00 committed by GitHub
parent 34fb066590
commit e58efbf0ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,6 @@ import (
"github.com/kaspanet/kaspad/blockdag"
"github.com/kaspanet/kaspad/dagconfig"
"github.com/kaspanet/kaspad/database"
"github.com/kaspanet/kaspad/mempool"
peerpkg "github.com/kaspanet/kaspad/peer"
"github.com/kaspanet/kaspad/util"
@ -495,18 +494,12 @@ func (sm *SyncManager) handleBlockMsg(bmsg *blockMsg) {
// rejected as opposed to something actually going wrong, so log
// it as such. Otherwise, something really did go wrong, so log
// it as an actual error.
if errors.As(err, &blockdag.RuleError{}) {
log.Infof("Rejected block %s from %s: %s", blockHash,
peer, err)
} else {
log.Errorf("Failed to process block %s: %s",
blockHash, err)
}
var dbErr database.Error
if ok := errors.As(err, &dbErr); ok && dbErr.ErrorCode ==
database.ErrCorruption {
panic(dbErr)
if !errors.As(err, &blockdag.RuleError{}) {
panic(errors.Wrapf(err, "Failed to process block %s",
blockHash))
}
log.Infof("Rejected block %s from %s: %s", blockHash,
peer, err)
// Convert the error into an appropriate reject message and
// send it.