From dcabe33f33d194706d86e360ab0c1e539ba5dfd6 Mon Sep 17 00:00:00 2001
From: Alex Sharov <AskAlexSharov@gmail.com>
Date: Fri, 11 Feb 2022 14:39:28 +0700
Subject: [PATCH]  Downloader: don't setup erigon's config if
 --dowloader.api.addr is set (#3480)

---
 cmd/utils/flags.go | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index f502b1a0e4..88bb64bb56 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -1362,18 +1362,14 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *node.Config, cfg *ethconfig.Conf
 		torrentPort = ctx.GlobalInt(TorrentPortFlag.Name)
 	}
 
-	TorrentPortFlag = cli.IntFlag{
-		Name:  "torrent.port",
-		Value: 42069,
-		Usage: "port to listen and serve BitTorrent protocol",
-	}
-
-	torrentCfg, pieceCompletion, err := torrentcfg.New(cfg.SnapshotDir, torrentVerbosity, downloadRate, uploadRate, torrentPort)
-	if err != nil {
-		panic(err)
+	if cfg.Snapshot.Enabled && !ctx.GlobalIsSet(DownloaderAddrFlag.Name) {
+		torrentCfg, pieceCompletion, err := torrentcfg.New(cfg.SnapshotDir, torrentVerbosity, downloadRate, uploadRate, torrentPort)
+		if err != nil {
+			panic(err)
+		}
+		cfg.Torrent = torrentCfg
+		cfg.TorrentPieceCompletionStorage = pieceCompletion
 	}
-	cfg.Torrent = torrentCfg
-	cfg.TorrentPieceCompletionStorage = pieceCompletion
 
 	if ctx.Command.Name == "import" {
 		cfg.ImportMode = true
-- 
GitLab