mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-20 22:54:19 +01:00
sauron: fail early if we can't get block hash in getrawblock
It's a bit of duplication but is nonsensical to make a block request if we couldn't get the block hash. Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
committed by
Christian Decker
parent
d013450f14
commit
dc3f691ea1
@@ -101,11 +101,16 @@ def getchaininfo(plugin, **kwargs):
|
||||
@plugin.method("getrawblockbyheight")
|
||||
def getrawblock(plugin, height, **kwargs):
|
||||
blockhash_url = "{}/block-height/{}".format(plugin.api_endpoint, height)
|
||||
|
||||
blockhash_req = fetch(blockhash_url)
|
||||
block_req = fetch("{}/block/{}/raw".format(plugin.api_endpoint,
|
||||
blockhash_req.text))
|
||||
if blockhash_req.status_code != 200 or block_req.status_code != 200:
|
||||
if blockhash_req.status_code != 200:
|
||||
return {
|
||||
"blockhash": None,
|
||||
"block": None,
|
||||
}
|
||||
|
||||
block_url = "{}/block/{}/raw".format(plugin.api_endpoint, blockhash_req.text)
|
||||
block_req = fetch(block_url)
|
||||
if block_req.status_code != 200:
|
||||
return {
|
||||
"blockhash": None,
|
||||
"block": None,
|
||||
|
||||
Reference in New Issue
Block a user