From 1231f8c21caf1771e18a4d3b5fc279592efd6f5f Mon Sep 17 00:00:00 2001
From: ledgerwatch <akhounov@gmail.com>
Date: Sun, 5 Jun 2022 11:39:27 +0100
Subject: [PATCH] Add bor mainnet to embed (#4370)

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
---
 turbo/snapshotsync/snapshothashes/embed.go  | 40 +++++++++++----------
 turbo/stages/headerdownload/header_algos.go |  2 +-
 2 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/turbo/snapshotsync/snapshothashes/embed.go b/turbo/snapshotsync/snapshothashes/embed.go
index 891a893178..8949a45ee4 100644
--- a/turbo/snapshotsync/snapshothashes/embed.go
+++ b/turbo/snapshotsync/snapshothashes/embed.go
@@ -31,6 +31,10 @@ var Ropsten = fromToml(ropsten)
 var mumbai []byte
 var Mumbai = fromToml(mumbai)
 
+//go:embed erigon-snapshots/bor-mainnet.toml
+var borMainnet []byte
+var BorMainnet = fromToml(borMainnet)
+
 type PreverifiedItem struct {
 	Name string
 	Hash string
@@ -55,11 +59,12 @@ func doSort(in preverified) Preverified {
 }
 
 var (
-	MainnetChainSnapshotConfig = newConfig(Mainnet)
-	GoerliChainSnapshotConfig  = newConfig(Goerli)
-	BscChainSnapshotConfig     = newConfig(Bsc)
-	RopstenChainSnapshotConfig = newConfig(Ropsten)
-	MumbaiChainSnapshotConfig  = newConfig(Mumbai)
+	MainnetChainSnapshotConfig    = newConfig(Mainnet)
+	GoerliChainSnapshotConfig     = newConfig(Goerli)
+	BscChainSnapshotConfig        = newConfig(Bsc)
+	RopstenChainSnapshotConfig    = newConfig(Ropsten)
+	MumbaiChainSnapshotConfig     = newConfig(Mumbai)
+	BorMainnetChainSnapshotConfig = newConfig(BorMainnet)
 )
 
 func newConfig(preverified Preverified) *Config {
@@ -101,19 +106,18 @@ type Config struct {
 	Preverified  Preverified
 }
 
+var KnownConfigs map[string]*Config = map[string]*Config{
+	networkname.MainnetChainName:    MainnetChainSnapshotConfig,
+	networkname.GoerliChainName:     GoerliChainSnapshotConfig,
+	networkname.BSCChainName:        BscChainSnapshotConfig,
+	networkname.RopstenChainName:    RopstenChainSnapshotConfig,
+	networkname.MumbaiChainName:     MumbaiChainSnapshotConfig,
+	networkname.BorMainnetChainName: BorMainnetChainSnapshotConfig,
+}
+
 func KnownConfig(networkName string) *Config {
-	switch networkName {
-	case networkname.MainnetChainName:
-		return MainnetChainSnapshotConfig
-	case networkname.GoerliChainName:
-		return GoerliChainSnapshotConfig
-	case networkname.BSCChainName:
-		return BscChainSnapshotConfig
-	case networkname.RopstenChainName:
-		return RopstenChainSnapshotConfig
-	case networkname.MumbaiChainName:
-		return MumbaiChainSnapshotConfig
-	default:
-		return newConfig(Preverified{})
+	if c, ok := KnownConfigs[networkName]; ok {
+		return c
 	}
+	return newConfig(Preverified{})
 }
diff --git a/turbo/stages/headerdownload/header_algos.go b/turbo/stages/headerdownload/header_algos.go
index 14bbb9bd97..7a1edc8eef 100644
--- a/turbo/stages/headerdownload/header_algos.go
+++ b/turbo/stages/headerdownload/header_algos.go
@@ -297,8 +297,8 @@ func (hd *HeaderDownload) logAnchorState() {
 		ss = append(ss, sb.String())
 	}
 	sort.Strings(ss)
+	log.Info("anchorQueue", "len", hd.anchorQueue.Len())
 	for _, s := range ss {
-		log.Info("anchorQueue", "len", hd.anchorQueue.Len())
 		log.Info(s)
 	}
 }
-- 
GitLab