Return RPC error if getBlock's lowHash doesn't exist (#1569)

Co-authored-by: Svarog <feanorr@gmail.com>
This commit is contained in:
Ori Newman
2021-03-02 16:21:55 +02:00
committed by GitHub
parent ce326b3c7d
commit 05df6e3e4e

View File

@@ -37,6 +37,17 @@ func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appm
Error: appmessage.RPCErrorf("Could not decode lowHash %s: %s", getBlocksRequest.LowHash, err),
}, nil
}
blockInfo, err := context.Domain.Consensus().GetBlockInfo(lowHash)
if err != nil {
return nil, err
}
if !blockInfo.Exists {
return &appmessage.GetBlocksResponseMessage{
Error: appmessage.RPCErrorf("Could not find lowHash %s", getBlocksRequest.LowHash),
}, nil
}
}
// Get hashes between lowHash and virtualSelectedParent