mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-09 07:36:43 +00:00
Make more checks if status is invalid even if the block exists (#2158)
* Make more checks if status is invalid even if the block exists * Use HasHeader
This commit is contained in:
parent
4d435f2b3a
commit
26c7db251f
@ -181,6 +181,10 @@ func (flow *handleIBDFlow) negotiateMissingSyncerChainSegment() (*externalapi.Do
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if info.Exists {
|
if info.Exists {
|
||||||
|
if info.BlockStatus == externalapi.StatusInvalid {
|
||||||
|
return nil, nil, protocolerrors.Errorf(true, "Sent invalid chain block %s", syncerChainHash)
|
||||||
|
}
|
||||||
|
|
||||||
currentHighestKnownSyncerChainHash = syncerChainHash
|
currentHighestKnownSyncerChainHash = syncerChainHash
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appm
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !blockInfo.Exists {
|
if !blockInfo.HasHeader() {
|
||||||
return &appmessage.GetBlocksResponseMessage{
|
return &appmessage.GetBlocksResponseMessage{
|
||||||
Error: appmessage.RPCErrorf("Could not find lowHash %s", getBlocksRequest.LowHash),
|
Error: appmessage.RPCErrorf("Could not find lowHash %s", getBlocksRequest.LowHash),
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -853,12 +853,16 @@ func (s *consensus) GetVirtualSelectedParentChainFromBlock(blockHash *externalap
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *consensus) validateBlockHashExists(stagingArea *model.StagingArea, blockHash *externalapi.DomainHash) error {
|
func (s *consensus) validateBlockHashExists(stagingArea *model.StagingArea, blockHash *externalapi.DomainHash) error {
|
||||||
exists, err := s.blockStatusStore.Exists(s.databaseContext, stagingArea, blockHash)
|
status, err := s.blockStatusStore.Get(s.databaseContext, stagingArea, blockHash)
|
||||||
|
if database.IsNotFoundError(err) {
|
||||||
|
return errors.Errorf("block %s does not exist", blockHash)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !exists {
|
|
||||||
return errors.Errorf("block %s does not exist", blockHash)
|
if status == externalapi.StatusInvalid {
|
||||||
|
return errors.Errorf("block %s is invalid", blockHash)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user