Skip to content

Commit b073d6a

Browse files
author
Dan Laine
committed
if indexing is disabled, don't die on indexer creation when there is an incomplete index
1 parent 91513d7 commit b073d6a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

indexer/indexer.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var (
4747
blockPrefix = byte(0x03)
4848
isIncompletePrefix = byte(0x04)
4949
previouslyIndexedPrefix = byte(0x05)
50-
hasRunKey = []byte{0x06}
50+
hasRunKey = []byte{0x07}
5151
)
5252

5353
var (
@@ -182,14 +182,6 @@ func (i *indexer) RegisterChain(name string, ctx *snow.Context, engine common.En
182182
return
183183
}
184184

185-
if !i.allowIncompleteIndex && isIncomplete && (previouslyIndexed || i.hasRunBefore) {
186-
i.log.Fatal("index %s is incomplete but incomplete indices are disabled. Shutting down", name)
187-
if err := i.close(); err != nil {
188-
i.log.Error("error while closing indexer: %s", err)
189-
}
190-
return
191-
}
192-
193185
if !i.indexingEnabled { // Indexing is disabled
194186
if previouslyIndexed && !i.allowIncompleteIndex {
195187
// We indexed this chain in a previous run but not in this run.
@@ -213,6 +205,15 @@ func (i *indexer) RegisterChain(name string, ctx *snow.Context, engine common.En
213205
return
214206
}
215207

208+
if !i.allowIncompleteIndex && isIncomplete && (previouslyIndexed || i.hasRunBefore) {
209+
i.log.Fatal("previously indexed: %v. has run before: %v", previouslyIndexed, i.hasRunBefore)
210+
i.log.Fatal("index %s is incomplete but incomplete indices are disabled. Shutting down", name)
211+
if err := i.close(); err != nil {
212+
i.log.Error("error while closing indexer: %s", err)
213+
}
214+
return
215+
}
216+
216217
// Mark that in this run, this chain was indexed
217218
if err := i.markPreviouslyIndexed(chainID); err != nil {
218219
i.log.Error("couldn't mark chain %s as indexed: %s", name, err)

0 commit comments

Comments
 (0)