diff --git a/lbrynet/core/LBRYWallet.py b/lbrynet/core/LBRYWallet.py index 3bcac43f6..4248194b7 100644 --- a/lbrynet/core/LBRYWallet.py +++ b/lbrynet/core/LBRYWallet.py @@ -494,6 +494,10 @@ class LBRYWallet(object): d.addCallback(self._get_decoded_tx) return d + def get_block_info(self, height): + d = self._get_blockhash(height) + return d + def get_history(self): d = self._get_history() return d @@ -862,6 +866,9 @@ class LBRYcrdWallet(LBRYWallet): def get_claims_from_tx(self, txid): return threads.deferToThread(self._get_claims_from_tx_rpc, txid) + def _get_blockhash(self, blockhash): + return threads.deferToThread(self._get_blockhash_rpc, blockhash) + def _get_value_for_name(self, name): return threads.deferToThread(self._get_value_for_name_rpc, name) @@ -994,6 +1001,11 @@ class LBRYcrdWallet(LBRYWallet): rpc_conn = self._get_rpc_conn() return rpc_conn.getblock(blockhash) + @_catch_connection_error + def _get_blockhash_rpc(self, height): + rpc_conn = self._get_rpc_conn() + return rpc_conn.getblockhash(height) + @_catch_connection_error def _get_claims_from_tx_rpc(self, txid): rpc_conn = self._get_rpc_conn() @@ -1247,6 +1259,11 @@ class LBRYumWallet(LBRYWallet): d.addCallback(lambda header: self.network.blockchain.hash_header(header)) return d + def _get_blockhash(self, height): + d = threads.deferToThread(self.network.blockchain.read_header, height) + d.addCallback(lambda header: self.network.blockchain.hash_header(header)) + return d + def get_name_claims(self): cmd = known_commands['getnameclaims'] func = getattr(self.cmd_runner, cmd.name) diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 9d2acd65a..f59ad099f 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -2255,10 +2255,13 @@ class LBRYDaemon(jsonrpc.JSONRPC): if 'blockhash' in p.keys(): blockhash = p['blockhash'] + d = self.session.wallet.get_block(blockhash) + elif 'height' in p.keys(): + height = p['height'] + d = self.session.wallet.get_block_info(height) + d.addCallback(lambda blockhash: self.session.wallet.get_block(blockhash)) else: return server.failure - - d = self.session.wallet.get_block(blockhash) d.addCallback(lambda r: self._render_response(r, OK_CODE)) return d