From 93d134f0ce50d4252bdd0113d906d4efb10dd0d0 Mon Sep 17 00:00:00 2001 From: shyba Date: Fri, 31 Aug 2018 14:12:13 -0300 Subject: [PATCH] [bug] remove get_block_info as it doesnt make sense, unify to get_block (#1425) --- lbrynet/daemon/Daemon.py | 10 +--------- lbrynet/wallet/manager.py | 10 +++++----- 2 files changed, 6 insertions(+), 14 deletions(-) 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)