From f3292b4d3425d2bdc7957c438bfdf467f0dd3477 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 17 Mar 2020 10:29:26 -0400 Subject: [PATCH] feedback --- lbry/wallet/account.py | 10 +++++----- lbry/wallet/database.py | 30 +++++++++++++++--------------- lbry/wallet/ledger.py | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lbry/wallet/account.py b/lbry/wallet/account.py index a315ea239..43fafa831 100644 --- a/lbry/wallet/account.py +++ b/lbry/wallet/account.py @@ -435,7 +435,7 @@ class Account: addresses.extend(new_addresses) return addresses - async def get_addresses(self, read_only: bool = False, **constraints) -> List[str]: + async def get_addresses(self, read_only=False, **constraints) -> List[str]: rows = await self.ledger.db.select_addresses('address', read_only=read_only, accounts=[self], **constraints) return [r[0] for r in rows] @@ -453,7 +453,7 @@ class Account: return self.address_managers[chain].get_public_key(index) def get_balance(self, confirmations: int = 0, include_claims: bool = False, - read_only: bool = False, **constraints): + read_only=False, **constraints): if not include_claims: constraints.update({'txo_type__in': (0, TXO_TYPES['purchase'])}) if confirmations > 0: @@ -563,7 +563,7 @@ class Account: if gap_changed: self.wallet.save() - async def get_detailed_balance(self, confirmations=0, reserved_subtotals=False, read_only: bool = False): + async def get_detailed_balance(self, confirmations=0, reserved_subtotals=False, read_only=False): tips_balance, supports_balance, claims_balance = 0, 0, 0 get_total_balance = partial(self.get_balance, read_only=read_only, confirmations=confirmations, include_claims=True) @@ -594,12 +594,12 @@ class Account: } if reserved_subtotals else None } - def get_transaction_history(self, read_only: bool = False, **constraints): + def get_transaction_history(self, read_only=False, **constraints): return self.ledger.get_transaction_history( read_only=read_only, wallet=self.wallet, accounts=[self], **constraints ) - def get_transaction_history_count(self, read_only: bool = False, **constraints): + def get_transaction_history_count(self, read_only=False, **constraints): return self.ledger.get_transaction_history_count( read_only=read_only, wallet=self.wallet, accounts=[self], **constraints ) diff --git a/lbry/wallet/database.py b/lbry/wallet/database.py index 03ccb2eeb..0795003f1 100644 --- a/lbry/wallet/database.py +++ b/lbry/wallet/database.py @@ -102,7 +102,7 @@ class AIOSQLite: return self.run(lambda conn: conn.executescript(script)) async def _execute_fetch(self, sql: str, parameters: Iterable = None, - read_only: bool = False, fetch_all: bool = False) -> Iterable[sqlite3.Row]: + read_only=False, fetch_all: bool = False) -> Iterable[sqlite3.Row]: read_only_fn = run_read_only_fetchall if fetch_all else run_read_only_fetchone parameters = parameters if parameters is not None else [] if read_only: @@ -116,11 +116,11 @@ class AIOSQLite: return await self.run(lambda conn: conn.execute(sql, parameters).fetchone()) async def execute_fetchall(self, sql: str, parameters: Iterable = None, - read_only: bool = False) -> Iterable[sqlite3.Row]: + read_only=False) -> Iterable[sqlite3.Row]: return await self._execute_fetch(sql, parameters, read_only, fetch_all=True) async def execute_fetchone(self, sql: str, parameters: Iterable = None, - read_only: bool = False) -> Iterable[sqlite3.Row]: + read_only=False) -> Iterable[sqlite3.Row]: return await self._execute_fetch(sql, parameters, read_only, fetch_all=False) def execute(self, sql: str, parameters: Iterable = None) -> Awaitable[sqlite3.Cursor]: @@ -561,7 +561,7 @@ class Database(SQLiteMixin): # 2. update address histories removing deleted TXs return True - async def select_transactions(self, cols, accounts=None, read_only: bool = False, **constraints): + async def select_transactions(self, cols, accounts=None, read_only=False, **constraints): if not {'txid', 'txid__in'}.intersection(constraints): assert accounts, "'accounts' argument required when no 'txid' constraint is present" where, values = constraints_to_sql({ @@ -651,7 +651,7 @@ class Database(SQLiteMixin): if txs: return txs[0] - async def select_txos(self, cols, wallet=None, include_is_received=False, read_only: bool = False, **constraints): + async def select_txos(self, cols, wallet=None, include_is_received=False, read_only=False, **constraints): if include_is_received: assert wallet is not None, 'cannot use is_recieved filter without wallet argument' account_in_wallet, values = constraints_to_sql({ @@ -675,7 +675,7 @@ class Database(SQLiteMixin): constraints['txoid__not_in'] = "SELECT txoid FROM txi" async def get_txos(self, wallet=None, no_tx=False, unspent=False, include_is_received=False, - read_only: bool = False, **constraints): + read_only=False, **constraints): include_is_received = include_is_received or 'is_received' in constraints if unspent: self.constrain_unspent(constraints) @@ -761,13 +761,13 @@ class Database(SQLiteMixin): count = await self.select_txos('count(*)', **constraints) return count[0][0] - def get_utxos(self, read_only: bool = False, **constraints): + def get_utxos(self, read_only=False, **constraints): return self.get_txos(unspent=True, read_only=read_only, **constraints) def get_utxo_count(self, **constraints): return self.get_txo_count(unspent=True, **constraints) - async def get_balance(self, wallet=None, accounts=None, read_only: bool = False, **constraints): + async def get_balance(self, wallet=None, accounts=None, read_only=False, **constraints): assert wallet or accounts, \ "'wallet' or 'accounts' constraints required to calculate balance" constraints['accounts'] = accounts or wallet.accounts @@ -775,13 +775,13 @@ class Database(SQLiteMixin): balance = await self.select_txos('SUM(amount)', read_only=read_only, **constraints) return balance[0][0] or 0 - async def select_addresses(self, cols, read_only: bool = False, **constraints): + async def select_addresses(self, cols, read_only=False, **constraints): return await self.db.execute_fetchall(*query( f"SELECT {cols} FROM pubkey_address JOIN account_address USING (address)", **constraints ), read_only=read_only) - async def get_addresses(self, cols=None, read_only: bool = False, **constraints): + async def get_addresses(self, cols=None, read_only=False, **constraints): cols = cols or ( 'address', 'account', 'chain', 'history', 'used_times', 'pubkey', 'chain_code', 'n', 'depth' @@ -795,11 +795,11 @@ class Database(SQLiteMixin): ) return addresses - async def get_address_count(self, cols=None, read_only: bool = False, **constraints): + async def get_address_count(self, cols=None, read_only=False, **constraints): count = await self.select_addresses('count(*)', read_only=read_only, **constraints) return count[0][0] - async def get_address(self, read_only: bool = False, **constraints): + async def get_address(self, read_only=False, **constraints): addresses = await self.get_addresses(read_only=read_only, limit=1, **constraints) if addresses: return addresses[0] @@ -864,7 +864,7 @@ class Database(SQLiteMixin): else: constraints['txo_type__in'] = CLAIM_TYPES - async def get_claims(self, read_only: bool = False, **constraints) -> List[Output]: + async def get_claims(self, read_only=False, **constraints) -> List[Output]: self.constrain_claims(constraints) return await self.get_utxos(read_only=read_only, **constraints) @@ -876,7 +876,7 @@ class Database(SQLiteMixin): def constrain_streams(constraints): constraints['txo_type'] = TXO_TYPES['stream'] - def get_streams(self, read_only: bool = False, **constraints): + def get_streams(self, read_only=False, **constraints): self.constrain_streams(constraints) return self.get_claims(read_only=read_only, **constraints) @@ -928,7 +928,7 @@ class Database(SQLiteMixin): " )", (account.public_key.address, ) ) - def get_supports_summary(self, account_id, read_only: bool = False): + def get_supports_summary(self, account_id, read_only=False): return self.db.execute_fetchall(f""" select txo.amount, exists(select * from txi where txi.txoid=txo.txoid) as spent, (txo.txid in diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index ba2256dec..64ac744c0 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -825,7 +825,7 @@ class Ledger(metaclass=LedgerRegistry): def get_support_count(self, **constraints): return self.db.get_support_count(**constraints) - async def get_transaction_history(self, read_only: bool = False, **constraints): + async def get_transaction_history(self, read_only=False, **constraints): txs: List[Transaction] = await self.db.get_transactions(read_only=read_only, **constraints) headers = self.headers history = [] @@ -935,7 +935,7 @@ class Ledger(metaclass=LedgerRegistry): history.append(item) return history - def get_transaction_history_count(self, read_only: bool = False, **constraints): + def get_transaction_history_count(self, read_only=False, **constraints): return self.db.get_transaction_count(read_only=read_only, **constraints) async def get_detailed_balance(self, accounts, confirmations=0):