Skip to content

Commit 36c628d

Browse files
Merge pull request #414 from ava-labs/add-general-indexer
Add general indexer fixes
2 parents 30458c3 + 4889c35 commit 36c628d

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

indexer/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestIndexClient(t *testing.T) {
4848
id = ids.GenerateTestID()
4949
client.EndpointRequester = &mockClient{
5050
f: func(reply interface{}) error {
51-
*(reply.(**GetContainerRangeResponse)) = &GetContainerRangeResponse{Containers: []FormattedContainer{{ID: id}}}
51+
*(reply.(*GetContainerRangeResponse)) = GetContainerRangeResponse{Containers: []FormattedContainer{{ID: id}}}
5252
return nil
5353
},
5454
}

indexer/indexer.go

Lines changed: 9 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,14 @@ 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("index %s is incomplete but incomplete indices are disabled. Shutting down", name)
210+
if err := i.close(); err != nil {
211+
i.log.Error("error while closing indexer: %s", err)
212+
}
213+
return
214+
}
215+
216216
// Mark that in this run, this chain was indexed
217217
if err := i.markPreviouslyIndexed(chainID); err != nil {
218218
i.log.Error("couldn't mark chain %s as indexed: %s", name, err)

indexer/indexer_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,6 @@ func TestIncompleteIndex(t *testing.T) {
502502
assert.NoError(err)
503503
idxr, ok = idxrIntf.(*indexer)
504504
assert.True(ok)
505-
506-
// Register the chain again. Should still die due to incomplete index.
507-
idxr.RegisterChain("chain1", chain1Ctx, chainEngine)
508-
assert.True(idxr.closed)
509505
}
510506

511507
// Ensure we only index chains in the primary network

0 commit comments

Comments
 (0)