[bug] remove get_block_info as it doesnt make sense, unify to get_block (#1425)

This commit is contained in:
shyba 2018-08-31 14:12:13 -03:00 committed by Lex Berezhny
parent 1c6ce49b7b
commit 93d134f0ce
2 changed files with 6 additions and 14 deletions

View file

@ -10,7 +10,6 @@ from operator import itemgetter
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from copy import deepcopy from copy import deepcopy
from decimal import Decimal, InvalidOperation from decimal import Decimal, InvalidOperation
from twisted.web import server
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from twisted.internet.task import LoopingCall from twisted.internet.task import LoopingCall
from twisted.python.failure import Failure from twisted.python.failure import Failure
@ -2511,14 +2510,7 @@ class Daemon(AuthJSONRPCServer):
Returns: Returns:
(dict) Requested block (dict) Requested block
""" """
return self.wallet.get_block(blockhash, height)
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
@requires(WALLET_COMPONENT, DHT_COMPONENT, BLOB_COMPONENT, RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT, @requires(WALLET_COMPONENT, DHT_COMPONENT, BLOB_COMPONENT, RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT,
conditions=[WALLET_IS_UNLOCKED]) conditions=[WALLET_IS_UNLOCKED])

View file

@ -291,12 +291,12 @@ class LbryWalletManager(BaseWalletManager):
for wallet in self.wallets: for wallet in self.wallets:
wallet.save() wallet.save()
def get_block(self, block_hash): def get_block(self, block_hash=None, height=None):
return self.ledger.network.get_block(block_hash) if height is None:
height = self.ledger.headers.height
def get_block_info(self, height): if block_hash is None:
block_hash = self.ledger.headers.hash(height).decode() block_hash = self.ledger.headers.hash(height).decode()
return self.get_block(block_hash) return self.ledger.network.get_block(block_hash)
def get_claim_by_claim_id(self, claim_id): def get_claim_by_claim_id(self, claim_id):
return self.ledger.get_claim_by_claim_id(claim_id) return self.ledger.get_claim_by_claim_id(claim_id)