forked from LBRYCommunity/lbry-sdk
vacuum before setting inputs
This commit is contained in:
parent
39d8a20fd5
commit
4b50d1e329
2 changed files with 27 additions and 14 deletions
|
@ -150,20 +150,22 @@ def process_inputs_outputs(initial_sync=False, p=None):
|
|||
|
||||
step = 1
|
||||
if initial_sync and p.ctx.is_postgres:
|
||||
p.start(4)
|
||||
p.start(6)
|
||||
else:
|
||||
p.start(2)
|
||||
|
||||
# 1. Update TXIs to have the address of TXO they are spending.
|
||||
set_input_addresses(p.ctx)
|
||||
# 0. Vacuum
|
||||
if initial_sync and p.ctx.is_postgres:
|
||||
with p.ctx.engine.connect() as c:
|
||||
c.execute(text("COMMIT;"))
|
||||
c.execute(text("VACUUM FULL ANALYZE txo;"))
|
||||
p.step(step)
|
||||
step += 1
|
||||
if initial_sync and p.ctx.is_postgres:
|
||||
p.ctx.execute(text("ALTER TABLE txi ADD PRIMARY KEY (txo_hash);"))
|
||||
c.execute(text("VACUUM FULL ANALYZE txi;"))
|
||||
p.step(step)
|
||||
step += 1
|
||||
|
||||
# 2. Update spent TXOs setting is_spent = True
|
||||
# 1. Update spent TXOs setting is_spent = True
|
||||
update_spent_outputs(p.ctx)
|
||||
p.step(step)
|
||||
step += 1
|
||||
|
@ -172,6 +174,15 @@ def process_inputs_outputs(initial_sync=False, p=None):
|
|||
p.step(step)
|
||||
step += 1
|
||||
|
||||
# 2. Update TXIs to have the address of TXO they are spending.
|
||||
set_input_addresses(p.ctx)
|
||||
p.step(step)
|
||||
step += 1
|
||||
if initial_sync and p.ctx.is_postgres:
|
||||
p.ctx.execute(text("ALTER TABLE txi ADD PRIMARY KEY (txo_hash);"))
|
||||
p.step(step)
|
||||
step += 1
|
||||
|
||||
|
||||
@sync_step(Event.BLOCK_FILTER, initial_sync=True, ongoing_sync=True)
|
||||
def process_block_filters(p=None):
|
||||
|
|
|
@ -535,11 +535,13 @@ class TestMultiBlockFileSyncing(BasicBlockchainTestCase):
|
|||
# 3 - db.sync.input
|
||||
self.assertEventsAlmostEqual(
|
||||
self.extract_events('db.sync.input', events), [
|
||||
[0, 4],
|
||||
[1, 4],
|
||||
[2, 4],
|
||||
[3, 4],
|
||||
[4, 4],
|
||||
[0, 6],
|
||||
[1, 6],
|
||||
[2, 6],
|
||||
[3, 6],
|
||||
[4, 6],
|
||||
[5, 6],
|
||||
[6, 6],
|
||||
] if self.db_driver == 'postgresql' else [
|
||||
[0, 2],
|
||||
[1, 2],
|
||||
|
|
Loading…
Reference in a new issue