From 34e816bf3ec776a85e57eaa18c5d572b1a94053e Mon Sep 17 00:00:00 2001 From: Gui Iribarren Date: Mon, 9 Sep 2024 17:55:56 +0200 Subject: [PATCH] (lts-backport) don't WaitUntilSync, just until BlockStore --- vochain/indexer/indexer.go | 13 ++++++++++++- vochain/indexer/migrations/0017_dummy.sql | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 vochain/indexer/migrations/0017_dummy.sql diff --git a/vochain/indexer/indexer.go b/vochain/indexer/indexer.go index c095c7e00..9574bbf06 100644 --- a/vochain/indexer/indexer.go +++ b/vochain/indexer/indexer.go @@ -433,7 +433,18 @@ func (idx *Indexer) AfterSyncBootstrap(inTest bool) { // ReindexBlocks reindexes all blocks found in blockstore func (idx *Indexer) ReindexBlocks(inTest bool) { if !inTest { - <-idx.App.WaitUntilSynced() + done := make(chan any) + go func() { + for idx.App == nil || + idx.App.Node == nil || + idx.App.Node.BlockStore() == nil { + log.Info("waiting for reindexing") + time.Sleep(time.Second * 1) + } + close(done) + }() + + <-done } // Note that holding blockMu means new votes aren't added until the reindex finishes. diff --git a/vochain/indexer/migrations/0017_dummy.sql b/vochain/indexer/migrations/0017_dummy.sql new file mode 100644 index 000000000..358e65d31 --- /dev/null +++ b/vochain/indexer/migrations/0017_dummy.sql @@ -0,0 +1,5 @@ +-- +goose Up +-- intentionally does nothing + +-- This is a no-op command in SQLite, used just to have a valid SQL statement. +SELECT 1;