Skip to content

Commit a11b50c

Browse files
authored
Merge pull request #202 from SiaFoundation/christopher/fix-hanging-on-start-again
2 parents 3dc566b + 99c3ebc commit a11b50c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

explorer/explorer.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,20 @@ func NewExplorer(cm ChainManager, store Store, indexCfg config.Index, scanCfg co
149149
}
150150
e.locator = locator
151151

152+
// add the genesis block if we do not have a tip
152153
if _, err := e.s.Tip(); errors.Is(err, ErrNoTip) {
153-
if err := e.syncStore(types.ChainIndex{}, 1); err != nil {
154-
e.log.Panic("failed to add genesis block", zap.Error(err))
154+
crus, caus, err := e.cm.UpdatesSince(types.ChainIndex{}, 1)
155+
if err != nil {
156+
return nil, fmt.Errorf("failed to get genesis block update: %w", err)
157+
}
158+
if err := e.s.UpdateChainState(crus, caus); err != nil {
159+
return nil, fmt.Errorf("failed to process genesis block updates: %w", err)
155160
}
156161
}
157162

158163
reorgChan := make(chan types.ChainIndex, 1)
164+
// get loop to start syncing immediately
165+
reorgChan <- types.ChainIndex{}
159166
go func() {
160167
for range reorgChan {
161168
lastTip, err := e.s.Tip()

0 commit comments

Comments
 (0)