code: def get_block_from_consensus(consensus_hash, hostport=None, proxy=None):
      
      assert hostport or proxy, 'Need hostport or proxy'
      if proxy is None:
          proxy = connect_hostport(hostport)
  
      consensus_schema = {
          'type': 'object',
          'properties': {
              'block_id': {
                  'anyOf': [
                      {
                          'type': 'integer',
                          'minimum': 0,
                      },
                      {
                          'type': 'null',
                      },
                  ],
              },
          },
          'required': [
              'block_id'
          ],
      }
  
      schema = json_response_schema( consensus_schema )
      resp = {}
      try:
          resp = proxy.get_block_from_consensus(consensus_hash)
          resp = json_validate( schema, resp )
          if json_is_error(resp):
              log.error("Failed to find block ID for %s" % consensus_hash)
              return resp
  
      except ValidationError as ve:
          if BLOCKSTACK_DEBUG:
              log.exception(ve)
  
          resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
          return resp
      
      except socket.timeout:
          log.error("Connection timed out")
          resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
          return resp
  
      except socket.error as se:
          log.error("Connection error {}".format(se.errno))
          resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
          return resp
  
      except Exception as ee:
          if BLOCKSTACK_DEBUG:
              log.exception(ee)
  
          log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
          resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
          return resp
  
      return resp['block_id']
docs: Get a block height from a consensus hash
      Returns the block height on success
      Returns {'error': ...} on failure