52 lines
955 B
Go
Raw Normal View History

2021-01-29 18:51:08 -03:00
package main
import (
"fmt"
2021-11-12 19:06:13 -03:00
"time"
2021-01-29 18:51:08 -03:00
"github.com/muun/recovery/electrum"
2021-11-12 19:06:13 -03:00
"github.com/muun/recovery/survey"
2021-01-29 18:51:08 -03:00
)
func main() {
2021-11-12 19:06:13 -03:00
config := &survey.Config{
InitialServers: electrum.PublicServers,
Workers: 30,
SpeedTestDuration: time.Second * 20,
SpeedTestBatchSize: 100,
2021-01-29 18:51:08 -03:00
}
2021-11-12 19:06:13 -03:00
survey := survey.NewSurvey(config)
results := survey.Run()
2021-01-29 18:51:08 -03:00
2021-11-12 19:06:13 -03:00
fmt.Println("\n\n// Worthy servers:")
for _, result := range results {
if result.IsWorthy {
fmt.Println(toCodeLine(result))
}
2021-01-29 18:51:08 -03:00
}
2021-11-12 19:06:13 -03:00
fmt.Println("\n\n// Unworthy servers:")
for _, result := range results {
if !result.IsWorthy {
fmt.Println(toCodeLine(result))
}
2021-01-29 18:51:08 -03:00
}
}
2021-11-12 19:06:13 -03:00
func toCodeLine(r *survey.Result) string {
if r.Err != nil {
return fmt.Sprintf("\"%s\", // %v", r.Server, r.Err)
2021-01-29 18:51:08 -03:00
}
2021-11-12 19:06:13 -03:00
return fmt.Sprintf(
"\"%s\", // impl: %s, batching: %v, ttc: %.2f, speed: %d, from: %s",
r.Server,
r.Impl,
r.BatchSupport,
r.TimeToConnect.Seconds(),
r.Speed,
r.FromPeer,
)
2021-01-29 18:51:08 -03:00
}