erigon-pulse/cmd/headers/commands/download.go
ledgerwatch 5834189019
Bodies download and simplify header download (#1471)
* Only insert hard-coded tips if both DB and files recovery failed

* Prevent deadlock

* Report some efficiency numbers

* Count properly unrequested bodies

* Initialise allRequests

* Increase timeout

* Fixes to scheduling

* Small fix

* Simplified scheduling

* Remove separate bodyLoop goroutine

* Update from DB at the beginnig of block bodies forward

* Timeout for repeating the request cycle

* Fix timeout

* Fix

* Increase timeout

* Increase timeout

* Try to make flow if possible

* Fix flow

* Lower timeout

* timeout for each blockNum

* Adjustable timeout

* Better log timing

* Track peers

* copy peerID

* fix scheduling

* Too much logging

* Print delivery speed

* Print committed blocks

* Fix race

* Sentry to only reset back-off timer when response to a request is received

* Print bytes/sec and wasted traffic

* Fix bandwidth accounting

* Less logging

* not to wake up on deliveries

* Spam every second

* Print peer map

* Fix npe, print requests

* Timestamps

* Improved logging

* Penalty for peers

* Log penalties only when disconnecting

* Try with smaller window

* window parameter

* Dealing with partially delivered requests

* Init bodyReq

* Fix array index

* More fix for NPE

* More NPE checks

* Print out body progress and header progress

* Fix ending condition

* Bring back waking up and penalties

* Fix duplicate tip

* Duplicate segment

* Fix lint

* Fix lint

* fix lint

* Fix lint

* Hard coded headers in the source files

* Fix lint

* Replace hix-sized header serialisation with rlp (to support clique)

* Remove anchor records from the files

* Fixeds for DB recovery

* Fix compilation

* Fix compile errors

* Fix formatting

* Fix lint

* Fix comments

* Remove headerLoop

* Properly terminate body download

* Support for StatusData p2p proto

* Fix forkid test

* Fix test

* Fix lint

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-02-08 09:25:10 +00:00

48 lines
2.1 KiB
Go

package commands
import (
"github.com/ledgerwatch/turbo-geth/cmd/headers/download"
"github.com/spf13/cobra"
)
var (
bufferSizeStr string // Size of buffer
combined bool // Whether downloader also includes sentry
timeout int // Timeout for delivery requests
window int // Size of sliding window for downloading block bodies
)
func init() {
downloadCmd.Flags().StringVar(&filesDir, "filesdir", "", "path to directory where files will be stored")
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>")
downloadCmd.Flags().BoolVar(&combined, "combined", false, "run downloader and sentry in the same process")
downloadCmd.Flags().IntVar(&timeout, "timeout", 10, "timeout for devp2p delivery requests, in seconds")
downloadCmd.Flags().IntVar(&window, "window", 8000, "size of sliding window for downloading block bodies, block")
// 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>")
withChaindata(downloadCmd)
withLmdbFlags(downloadCmd)
rootCmd.AddCommand(downloadCmd)
}
var downloadCmd = &cobra.Command{
Use: "download",
Short: "Download headers backwards",
RunE: func(cmd *cobra.Command, args []string) error {
db := openDatabase(chaindata)
defer db.Close()
if combined {
return download.Combined(natSetting, port, staticPeers, discovery, netRestrict, filesDir, bufferSizeStr, db, timeout, window)
}
return download.Download(filesDir, bufferSizeStr, sentryAddr, coreAddr, db, timeout, window)
},
}