forked from LBRYCommunity/lbry-sdk
bug fixes and performance improvements
This commit is contained in:
parent
7a4e5dcb05
commit
1790ee3018
4 changed files with 7 additions and 6 deletions
|
@ -126,12 +126,12 @@ def sync_txoi(initial_sync: bool, p: ProgressContext):
|
||||||
p.step()
|
p.step()
|
||||||
else:
|
else:
|
||||||
p.start(2)
|
p.start(2)
|
||||||
# 1. Update TXIs to have the address of TXO they are spending.
|
# 1. Update spent TXOs setting spent_height
|
||||||
set_input_addresses(p.ctx)
|
|
||||||
p.step()
|
|
||||||
# 2. Update spent TXOs setting spent_height
|
|
||||||
update_spent_outputs(p.ctx)
|
update_spent_outputs(p.ctx)
|
||||||
p.step()
|
p.step()
|
||||||
|
# 2. Update TXIs to have the address of TXO they are spending.
|
||||||
|
set_input_addresses(p.ctx)
|
||||||
|
p.step()
|
||||||
|
|
||||||
|
|
||||||
@event_emitter("blockchain.sync.filter.generate", "blocks")
|
@event_emitter("blockchain.sync.filter.generate", "blocks")
|
||||||
|
|
|
@ -134,12 +134,12 @@ def distribute_unspent_txos(
|
||||||
total = 0
|
total = 0
|
||||||
buckets = []
|
buckets = []
|
||||||
for bucket in context().fetchall(sql):
|
for bucket in context().fetchall(sql):
|
||||||
|
total += bucket['items']
|
||||||
if len(buckets) > 0:
|
if len(buckets) > 0:
|
||||||
if buckets[-1][-1] == bucket['start_height']:
|
if buckets[-1][-1] == bucket['start_height']:
|
||||||
if bucket['start_height'] == bucket['end_height']:
|
if bucket['start_height'] == bucket['end_height']:
|
||||||
continue
|
continue
|
||||||
bucket['start_height'] += 1
|
bucket['start_height'] += 1
|
||||||
total += bucket['items']
|
|
||||||
buckets.append((bucket['start_height'], bucket['end_height']))
|
buckets.append((bucket['start_height'], bucket['end_height']))
|
||||||
return total, buckets
|
return total, buckets
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ def update_spent_outputs(ctx):
|
||||||
)
|
)
|
||||||
}).where(
|
}).where(
|
||||||
(TXO.c.spent_height == 0) &
|
(TXO.c.spent_height == 0) &
|
||||||
(TXO.c.txo_hash.in_(select(TXI.c.txo_hash)))
|
(TXO.c.txo_hash.in_(select(TXI.c.txo_hash).where(TXI.c.address.is_(None))))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
ctx.execute(set_spent_height)
|
ctx.execute(set_spent_height)
|
||||||
|
|
|
@ -200,6 +200,7 @@ Support = Table(
|
||||||
Column('address', Text),
|
Column('address', Text),
|
||||||
Column('amount', BigInteger),
|
Column('amount', BigInteger),
|
||||||
Column('height', Integer),
|
Column('height', Integer),
|
||||||
|
Column('timestamp', Integer),
|
||||||
|
|
||||||
# support metadata
|
# support metadata
|
||||||
Column('emoji', Text),
|
Column('emoji', Text),
|
||||||
|
|
Loading…
Reference in a new issue