mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-1229] Fix node crashing if AntiPastHashesBetween lowHigh or highHash are not found in the DAG (#849)
* [NOD-1229] Fix node crashing if AntiPastHashesBetween lowHigh or highHash are not found in the DAG * [NOD-1229] Rename InvalidParameterError to ErrInvalidParameter. * [NOD-1229] Lowercasify errors.
This commit is contained in:
parent
420c3d4258
commit
b55cfee8c8
@ -1851,14 +1851,14 @@ func (dag *BlockDAG) antiPastHashesBetween(lowHash, highHash *daghash.Hash, maxH
|
||||
func (dag *BlockDAG) antiPastBetween(lowHash, highHash *daghash.Hash, maxEntries uint64) ([]*blockNode, error) {
|
||||
lowNode, ok := dag.index.LookupNode(lowHash)
|
||||
if !ok {
|
||||
return nil, errors.Errorf("Couldn't find low hash %s", lowHash)
|
||||
return nil, errors.Wrapf(ErrInvalidParameter, "couldn't find low hash %s", lowHash)
|
||||
}
|
||||
highNode, ok := dag.index.LookupNode(highHash)
|
||||
if !ok {
|
||||
return nil, errors.Errorf("Couldn't find high hash %s", highHash)
|
||||
return nil, errors.Wrapf(ErrInvalidParameter, "couldn't find high hash %s", highHash)
|
||||
}
|
||||
if lowNode.blueScore >= highNode.blueScore {
|
||||
return nil, errors.Errorf("Low hash blueScore >= high hash blueScore (%d >= %d)",
|
||||
return nil, errors.Wrapf(ErrInvalidParameter, "low hash blueScore >= high hash blueScore (%d >= %d)",
|
||||
lowNode.blueScore, highNode.blueScore)
|
||||
}
|
||||
|
||||
|
@ -287,3 +287,7 @@ func (e RuleError) Error() string {
|
||||
func ruleError(c ErrorCode, desc string) error {
|
||||
return errors.WithStack(RuleError{ErrorCode: c, Description: desc})
|
||||
}
|
||||
|
||||
// ErrInvalidParameter signifies that an invalid parameter has been
|
||||
// supplied to one of the BlockDAG functions.
|
||||
var ErrInvalidParameter = errors.New("invalid parameter")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ibd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/kaspanet/kaspad/blockdag"
|
||||
"github.com/kaspanet/kaspad/netadapter/router"
|
||||
"github.com/kaspanet/kaspad/protocol/protocolerrors"
|
||||
@ -95,6 +96,10 @@ func (flow *handleRequestBlocksFlow) buildMsgIBDBlocks(lowHash *daghash.Hash,
|
||||
const maxHashesInMsgIBDBlocks = wire.MaxInvPerMsg
|
||||
blockHashes, err := flow.DAG().AntiPastHashesBetween(lowHash, highHash, maxHashesInMsgIBDBlocks)
|
||||
if err != nil {
|
||||
if errors.Is(err, blockdag.ErrInvalidParameter) {
|
||||
return nil, protocolerrors.Wrapf(true, err, "could not get antiPast between "+
|
||||
"%s and %s", lowHash, highHash)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user