2020-09-07 06:03:12 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/headers/download"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-10-25 22:05:37 +00:00
|
|
|
bufferSizeStr string // Size of buffer
|
2021-01-15 10:58:04 +00:00
|
|
|
combined bool // Whether downloader also includes sentry
|
2020-09-07 06:03:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
downloadCmd.Flags().StringVar(&filesDir, "filesdir", "", "path to directory where files will be stored")
|
2020-10-25 22:05:37 +00:00
|
|
|
downloadCmd.Flags().StringVar(&bufferSizeStr, "bufferSize", "512M", "size o the buffer")
|
|
|
|
downloadCmd.Flags().StringVar(&sentryAddr, "sentryAddr", "localhost:9091", "sentry address <host>:<port>")
|
|
|
|
downloadCmd.Flags().StringVar(&coreAddr, "coreAddr", "localhost:9092", "core address <host>:<port>")
|
2021-01-15 10:58:04 +00:00
|
|
|
downloadCmd.Flags().BoolVar(&combined, "combined", false, "run downloader and sentry in the same process")
|
|
|
|
|
|
|
|
// Options below are only used in the combined mode
|
|
|
|
downloadCmd.Flags().StringVar(&natSetting, "nat", "any", "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
|
|
|
|
downloadCmd.Flags().IntVar(&port, "port", 30303, "p2p port number")
|
|
|
|
downloadCmd.Flags().StringArrayVar(&staticPeers, "staticpeers", []string{}, "static peer list [enode]")
|
|
|
|
downloadCmd.Flags().BoolVar(&discovery, "discovery", true, "discovery mode")
|
|
|
|
downloadCmd.Flags().StringVar(&netRestrict, "netrestrict", "", "CIDR range to accept peers from <CIDR>")
|
|
|
|
|
2020-11-02 21:09:12 +00:00
|
|
|
withChaindata(downloadCmd)
|
|
|
|
withLmdbFlags(downloadCmd)
|
2020-09-07 06:03:12 +00:00
|
|
|
rootCmd.AddCommand(downloadCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var downloadCmd = &cobra.Command{
|
|
|
|
Use: "download",
|
|
|
|
Short: "Download headers backwards",
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2020-11-02 21:09:12 +00:00
|
|
|
db := openDatabase(chaindata)
|
|
|
|
defer db.Close()
|
2021-01-15 10:58:04 +00:00
|
|
|
if combined {
|
|
|
|
return download.Combined(natSetting, port, staticPeers, discovery, netRestrict, filesDir, bufferSizeStr, db)
|
|
|
|
}
|
2020-11-02 21:09:12 +00:00
|
|
|
return download.Download(filesDir, bufferSizeStr, sentryAddr, coreAddr, db)
|
2020-09-07 06:03:12 +00:00
|
|
|
},
|
|
|
|
}
|