diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index a326cac81..c65f3912e 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -10,7 +10,6 @@ from operator import itemgetter from binascii import hexlify, unhexlify from copy import deepcopy from decimal import Decimal, InvalidOperation -from twisted.web import server from twisted.internet import defer, reactor from twisted.internet.task import LoopingCall from twisted.python.failure import Failure @@ -2511,14 +2510,7 @@ class Daemon(AuthJSONRPCServer): Returns: (dict) Requested block """ - - if blockhash is not None: - return self.wallet.get_block(blockhash) - elif height is not None: - return self.wallet.get_block_info(height) - else: - # TODO: return a useful error message - return server.failure + return self.wallet.get_block(blockhash, height) @requires(WALLET_COMPONENT, DHT_COMPONENT, BLOB_COMPONENT, RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT, conditions=[WALLET_IS_UNLOCKED]) diff --git a/lbrynet/wallet/manager.py b/lbrynet/wallet/manager.py index 9a9116bca..5c57b3a9e 100644 --- a/lbrynet/wallet/manager.py +++ b/lbrynet/wallet/manager.py @@ -291,13 +291,13 @@ class LbryWalletManager(BaseWalletManager): for wallet in self.wallets: wallet.save() - def get_block(self, block_hash): + def get_block(self, block_hash=None, height=None): + if height is None: + height = self.ledger.headers.height + if block_hash is None: + block_hash = self.ledger.headers.hash(height).decode() return self.ledger.network.get_block(block_hash) - def get_block_info(self, height): - block_hash = self.ledger.headers.hash(height).decode() - return self.get_block(block_hash) - def get_claim_by_claim_id(self, claim_id): return self.ledger.get_claim_by_claim_id(claim_id)