mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-09 12:31:21 +00:00
81ea5bab78
* Initial commit * Add sentry gRPC interface * p2psentry directory * Update README.md * Update README.md * Update README.md * Add go package * Correct syntax * add external downloader interface (#2) * Add txpool (#3) * Add private API (#4) * Invert control.proto, add PeerMinBlock, Separare incoming Tx message into a separate stream (#5) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Separate upload messages into its own stream (#6) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Only send changed accounts to listeners (#7) * Txpool interface doc (#9) * More additions * More additions * Fix locking * Intermediate * Fix separation of phases * Intermediate * Fix test * More transformations * New simplified way of downloading headers * Fix hard-coded header sync * Fixed syncing near the tip of the chain * Add architecture diagram source and picture (#10) * More fixes * rename tip to link * Use preverified hashes instead of preverified headers * Fix preverified hashes generation * more parametrisation * Continue parametrisation * Fix grpc data limit, interruption of headers stage * Add ropsten preverified hashes * Typed hashes (#11) * Typed hashes * Fix PeerId * 64-bit tx nonce * Disable penalties * Add goerli settings, bootstrap nodes * Try to fix goerly sync * Remove interfaces * Add proper golang packages, max_block into p2p sentry Status * Prepare for proto overhaul * Squashed 'interfaces/' content from commit ce36053c2 git-subtree-dir: interfaces git-subtree-split: ce36053c24db2f56e48ac752808de60afa1dfb4b * Change EtherReply to address * Adaptations to new types * Switch to new types * Fixes * Fix formatting * Fix lint * Lint fixes, reverse order in types * Fix lint * Fix lint * Fix lint * Fix test * Not supporting eth/66 yet * Fix shutdown * Fix lint * Fix lint * Fix lint * return stopped check Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me> Co-authored-by: b00ris <b00ris@mail.ru> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> Co-authored-by: canepat <16927169+canepat@users.noreply.github.com>
123 lines
3.0 KiB
Go
123 lines
3.0 KiB
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/c2h5oh/datasize"
|
|
"github.com/ledgerwatch/turbo-geth/cmd/utils"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
"github.com/ledgerwatch/turbo-geth/internal/debug"
|
|
"github.com/ledgerwatch/turbo-geth/log"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
sentryAddr string // Address of the sentry <host>:<port>
|
|
coreAddr string // Address of the core <host>:<port>
|
|
chaindata string // Path to chaindata
|
|
database string // Type of database (lmdb or mdbx)
|
|
mapSizeStr string // Map size for LMDB
|
|
freelistReuse int
|
|
)
|
|
|
|
func init() {
|
|
utils.CobraFlags(rootCmd, append(debug.Flags, utils.MetricFlags...))
|
|
}
|
|
|
|
func rootContext() context.Context {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
go func() {
|
|
ch := make(chan os.Signal, 1)
|
|
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
|
|
defer signal.Stop(ch)
|
|
|
|
select {
|
|
case <-ch:
|
|
log.Info("Got interrupt, shutting down...")
|
|
case <-ctx.Done():
|
|
}
|
|
|
|
cancel()
|
|
}()
|
|
return ctx
|
|
}
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "headers",
|
|
Short: "headers is Proof Of Concept for new header/block downloading algorithms",
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
if err := debug.SetupCobra(cmd); err != nil {
|
|
panic(err)
|
|
}
|
|
},
|
|
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
|
debug.Exit()
|
|
},
|
|
}
|
|
|
|
func Execute() {
|
|
if err := rootCmd.ExecuteContext(rootContext()); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func must(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func withChaindata(cmd *cobra.Command) {
|
|
cmd.Flags().StringVar(&chaindata, "chaindata", "", "path to the db")
|
|
must(cmd.MarkFlagDirname("chaindata"))
|
|
must(cmd.MarkFlagRequired("chaindata"))
|
|
cmd.Flags().StringVar(&database, "database", "", "lmdb|mdbx")
|
|
}
|
|
|
|
func withLmdbFlags(cmd *cobra.Command) {
|
|
cmd.Flags().StringVar(&mapSizeStr, "lmdb.mapSize", "", "map size for LMDB")
|
|
cmd.Flags().IntVar(&freelistReuse, "maxFreelistReuse", 0, "Find a big enough contiguous page range for large values in freelist is hard just allocate new pages and even don't try to search if value is bigger than this limit. Measured in pages.")
|
|
}
|
|
|
|
func openDatabase(path string) *ethdb.ObjectDatabase {
|
|
db := ethdb.NewObjectDatabase(openKV(path, false))
|
|
return db
|
|
}
|
|
|
|
func openKV(path string, exclusive bool) ethdb.KV {
|
|
if database == "mdbx" {
|
|
opts := ethdb.NewMDBX().Path(path)
|
|
if exclusive {
|
|
opts = opts.Exclusive()
|
|
}
|
|
if mapSizeStr != "" {
|
|
var mapSize datasize.ByteSize
|
|
must(mapSize.UnmarshalText([]byte(mapSizeStr)))
|
|
opts = opts.MapSize(mapSize)
|
|
}
|
|
if freelistReuse > 0 {
|
|
opts = opts.MaxFreelistReuse(uint(freelistReuse))
|
|
}
|
|
return opts.MustOpen()
|
|
}
|
|
|
|
opts := ethdb.NewLMDB().Path(path)
|
|
if exclusive {
|
|
opts = opts.Exclusive()
|
|
}
|
|
if mapSizeStr != "" {
|
|
var mapSize datasize.ByteSize
|
|
must(mapSize.UnmarshalText([]byte(mapSizeStr)))
|
|
opts = opts.MapSize(mapSize)
|
|
}
|
|
if freelistReuse > 0 {
|
|
opts = opts.MaxFreelistReuse(uint(freelistReuse))
|
|
}
|
|
return opts.MustOpen()
|
|
}
|