Skip to content

Commit

Permalink
fix(core-json-rpc): return 404 if the last block is not found
Browse files Browse the repository at this point in the history
This should never happen unless, obviously, your node is not synced.
  • Loading branch information
faustbrian authored Dec 6, 2018
1 parent 9817e23 commit adc554f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core-json-rpc/lib/server/methods/blocks/latest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const Boom = require('boom')
const network = require('../../services/network')

module.exports = {
Expand All @@ -7,6 +8,8 @@ module.exports = {
'blocks?orderBy=height:desc&limit=1',
)

return response.data[0]
return response
? response.data[0]
: Boom.notFound(`Latest block could not be found.`)
},
}

0 comments on commit adc554f

Please sign in to comment.