node-http: add check for height being below tip

This commit simply adds an enforce line to check that the height being
requested to reset to is below the chain tip. This way we return a bad
request error rather than a internal server error.
This commit is contained in:
kilpatty 2019-04-30 21:43:48 -05:00
parent d601b6a303
commit d5514d9dcb
No known key found for this signature in database
GPG Key ID: 2346BDEEAEF0F2D3

View File

@ -339,6 +339,8 @@ class HTTP extends Server {
const height = valid.u32('height');
enforce(height != null, 'Height is required.');
enforce(height <= this.chain.height,
'Height cannot be greater than chain tip.');
await this.chain.reset(height);