Skip to content

Commit cec4c9b

Browse files
chris124567ChrisSchinnerl
authored andcommitted
add genesis block in NewExplorer
1 parent e41e9df commit cec4c9b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

explorer/explorer.go

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

152+
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))
155+
}
156+
}
157+
152158
reorgChan := make(chan types.ChainIndex, 1)
153159
go func() {
154160
for range reorgChan {

persist/sqlite/scan_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func TestScan(t *testing.T) {
378378
t.Helper()
379379

380380
for {
381-
if tip, err := e.Tip(); err != nil && !errors.Is(err, explorer.ErrNoTip) {
381+
if tip, err := e.Tip(); err != nil {
382382
t.Fatal(err)
383383
} else if tip == cm.Tip() {
384384
break

0 commit comments

Comments
 (0)