@@ -93,16 +93,16 @@ def GetByIdBase(db_client, rpccaller, chain, resource, req_id):
9393
9494def GetBlockByHeight (db_client , rpccaller , chain , height ):
9595 criteria = {'height' : height }
96- count_by_height = db_client . search (chain + "_" + 'block' , criteria )
97- if len (count_by_height ) > 1 :
96+ block_by_height = model . Block . search (criteria , namespace = chain , minql_client = db_client )
97+ if len (block_by_height ) > 1 :
9898 return {'error' : {'message' : 'More than one block cached for height %s' % height }}
99- if len (count_by_height ) == 1 :
100- return json .loads (count_by_height [0 ][ ' blob' ] )
99+ if len (block_by_height ) == 1 :
100+ return json .loads (block_by_height [0 ]. blob )
101101
102- json_result = rpccaller .RpcCall ('getblockhash' , {'height' : height })
103- if 'error' in json_result :
104- return json_result
105- return GetByIdBase ( db_client , rpccaller , chain , 'block' , json_result )
102+ blockhash = rpccaller .RpcCall ('getblockhash' , {'height' : height })
103+ if 'error' in blockhash :
104+ return blockhash
105+ return model . Block . get ( blockhash , namespace = chain , minql_client = db_client ). json ( )
106106
107107def GetById (db_client , rpccaller , chain , resource , req_id ):
108108 if resource == 'blockheight' :
0 commit comments