From e7668cab6be057191ee826fee2dee9d0dc2caab7 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 26 Sep 2024 17:17:12 -0600 Subject: [PATCH] fix: regen addrbook json (#624) * regenerate addrbook.json * lint * change perms --- server/start.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/start.go b/server/start.go index 7b923033540c..488ae0270735 100644 --- a/server/start.go +++ b/server/start.go @@ -7,6 +7,7 @@ import ( "io" "net" "os" + "path/filepath" "runtime/pprof" "strings" "time" @@ -750,6 +751,17 @@ func testnetify(ctx *Context, testnetAppCreator types.AppCreator, db dbm.DB, tra return nil, err } + // Regenerate addrbook.json to prevent peers on old network from causing error logs. + addrBookPath := filepath.Join(config.RootDir, "config", "addrbook.json") + if err := os.Remove(addrBookPath); err != nil && !os.IsNotExist(err) { + return nil, fmt.Errorf("failed to remove existing addrbook.json: %w", err) + } + + emptyAddrBook := []byte("{}") + if err := os.WriteFile(addrBookPath, emptyAddrBook, 0o600); err != nil { + return nil, fmt.Errorf("failed to create empty addrbook.json: %w", err) + } + // Load the comet genesis doc provider. genDocProvider := node.DefaultGenesisDocProviderFunc(config)