mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-08-27 07:23:24 +00:00
fix balance with confirmations and header event reporting
This commit is contained in:
parent
2f83ebb3b5
commit
25046124c0
3 changed files with 5 additions and 3 deletions
|
@ -262,7 +262,7 @@ class BaseAccount(object):
|
||||||
def get_balance(self, confirmations=6, **constraints):
|
def get_balance(self, confirmations=6, **constraints):
|
||||||
if confirmations > 0:
|
if confirmations > 0:
|
||||||
height = self.ledger.headers.height - (confirmations-1)
|
height = self.ledger.headers.height - (confirmations-1)
|
||||||
constraints.update({'height__lte': height, 'height__not': -1})
|
constraints.update({'height__lte': height, 'height__gt': 0})
|
||||||
return self.ledger.db.get_balance_for_account(self, **constraints)
|
return self.ledger.db.get_balance_for_account(self, **constraints)
|
||||||
|
|
||||||
def get_unspent_outputs(self, **constraints):
|
def get_unspent_outputs(self, **constraints):
|
||||||
|
|
|
@ -232,6 +232,8 @@ class BaseDatabase(SQLiteMixin):
|
||||||
col, op = key[:-len('__not')], '!='
|
col, op = key[:-len('__not')], '!='
|
||||||
elif key.endswith('__lte'):
|
elif key.endswith('__lte'):
|
||||||
col, op = key[:-len('__lte')], '<='
|
col, op = key[:-len('__lte')], '<='
|
||||||
|
elif key.endswith('__gt'):
|
||||||
|
col, op = key[:-len('__gt')], '>'
|
||||||
extras.append('{} {} :{}'.format(col, op, key))
|
extras.append('{} {} :{}'.format(col, op, key))
|
||||||
extra_sql = ' AND ' + ' AND '.join(extras)
|
extra_sql = ' AND ' + ' AND '.join(extras)
|
||||||
if not include_reserved:
|
if not include_reserved:
|
||||||
|
|
|
@ -212,7 +212,7 @@ class BaseLedger(six.with_metaclass(LedgerRegistry)):
|
||||||
if headers['count'] <= 0:
|
if headers['count'] <= 0:
|
||||||
break
|
break
|
||||||
yield self.headers.connect(height_sought, unhexlify(headers['hex']))
|
yield self.headers.connect(height_sought, unhexlify(headers['hex']))
|
||||||
self._on_header_controller.add(height_sought)
|
self._on_header_controller.add(self.headers.height)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def process_header(self, response):
|
def process_header(self, response):
|
||||||
|
@ -222,7 +222,7 @@ class BaseLedger(six.with_metaclass(LedgerRegistry)):
|
||||||
if header['height'] == len(self.headers):
|
if header['height'] == len(self.headers):
|
||||||
# New header from network directly connects after the last local header.
|
# New header from network directly connects after the last local header.
|
||||||
yield self.headers.connect(len(self.headers), unhexlify(header['hex']))
|
yield self.headers.connect(len(self.headers), unhexlify(header['hex']))
|
||||||
self._on_header_controller.add(len(self.headers))
|
self._on_header_controller.add(self.headers.height)
|
||||||
elif header['height'] > len(self.headers):
|
elif header['height'] > len(self.headers):
|
||||||
# New header is several heights ahead of local, do download instead.
|
# New header is several heights ahead of local, do download instead.
|
||||||
yield self.update_headers()
|
yield self.update_headers()
|
||||||
|
|
Loading…
Add table
Reference in a new issue