Jelajahi Sumber

eth/downloader: review fixes

Péter Szilágyi 8 tahun lalu
induk
melakukan
8676aeb798
2 mengubah file dengan 13 tambahan dan 7 penghapusan
  1. 1 1
      eth/downloader/downloader.go
  2. 12 6
      eth/downloader/modes.go

+ 1 - 1
eth/downloader/downloader.go

@@ -383,7 +383,7 @@ func (d *Downloader) syncWithPeer(p *peer, hash common.Hash, td *big.Int) (err e
 		return errTooOld
 	}
 
-	log.Debug("Synchronising with the network", "peer", p.id, "eth", p.version, "head", hash.Hex()[2:10], "td", td, "mode", syncModeLabels[d.mode])
+	log.Debug("Synchronising with the network", "peer", p.id, "eth", p.version, "head", hash.Hex()[2:10], "td", td, "mode", d.mode)
 	defer func(start time.Time) {
 		log.Debug("Synchronisation terminated", "elapsed", time.Since(start))
 	}(time.Now())

+ 12 - 6
eth/downloader/modes.go

@@ -25,10 +25,16 @@ const (
 	LightSync                 // Download only the headers and terminate afterwards
 )
 
-// syncModeLabels contains a mapping of sync modes to textual label used by the
-// logging system.
-var syncModeLabels = map[SyncMode]string{
-	FullSync:  "full",
-	FastSync:  "fast",
-	LightSync: "light",
+// String implements the stringer interface.
+func (mode SyncMode) String() string {
+	switch mode {
+	case FullSync:
+		return "full"
+	case FastSync:
+		return "fast"
+	case LightSync:
+		return "light"
+	default:
+		return "unknown"
+	}
 }