Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 12 additions & 28 deletions rocketpool/node/node.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package node

import (
_ "embed"
"fmt"
"math/big"
"net/http"
Expand All @@ -25,8 +26,13 @@ import (
)

// Config
var tasksInterval, _ = time.ParseDuration("5m")
var taskCooldown, _ = time.ParseDuration("10s")
var (
tasksInterval, _ = time.ParseDuration("5m")
taskCooldown, _ = time.ParseDuration("10s")
)

//go:embed saturn-art.txt
var saturnArt string

const (
MaxConcurrentEth1Requests = 200
Expand Down Expand Up @@ -63,7 +69,6 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {

// Run daemon
func run(c *cli.Context) error {

// Handle the initial fee recipient file deployment
err := deployDefaultFeeRecipientFile(c)
if err != nil {
Expand Down Expand Up @@ -338,22 +343,18 @@ func run(c *cli.Context) error {
// Wait for both threads to stop
wg.Wait()
return nil

}

// Configure HTTP transport settings
func configureHTTP() {

// The daemon makes a large number of concurrent RPC requests to the Eth1 client
// The HTTP transport is set to cache connections for future re-use equal to the maximum expected number of concurrent requests
// This prevents issues related to memory consumption and address allowance from repeatedly opening and closing connections
http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = MaxConcurrentEth1Requests

}

// Copy the default fee recipient file into the proper location
func deployDefaultFeeRecipientFile(c *cli.Context) error {

cfg, err := services.GetConfig(c)
if err != nil {
return err
Expand All @@ -364,7 +365,7 @@ func deployDefaultFeeRecipientFile(c *cli.Context) error {
if os.IsNotExist(err) {
// Make sure the validators dir is created
validatorsFolder := filepath.Dir(feeRecipientPath)
err = os.MkdirAll(validatorsFolder, 0755)
err = os.MkdirAll(validatorsFolder, 0o755)
if err != nil {
return fmt.Errorf("could not create validators directory: %w", err)
}
Expand All @@ -378,7 +379,7 @@ func deployDefaultFeeRecipientFile(c *cli.Context) error {
// Docker and Hybrid just need the address itself
defaultFeeRecipientFileContents = cfg.Smartnode.GetRethAddress().Hex()
}
err := os.WriteFile(feeRecipientPath, []byte(defaultFeeRecipientFileContents), 0664)
err := os.WriteFile(feeRecipientPath, []byte(defaultFeeRecipientFileContents), 0o664)
if err != nil {
return fmt.Errorf("could not write default fee recipient file to %s: %w", feeRecipientPath, err)
}
Expand All @@ -387,12 +388,10 @@ func deployDefaultFeeRecipientFile(c *cli.Context) error {
}

return nil

}

// Remove the old fee recipient files that were created in v1.5.0
func removeLegacyFeeRecipientFiles(c *cli.Context) error {

legacyFeeRecipientFile := "rp-fee-recipient.txt"

cfg, err := services.GetConfig(c)
Expand All @@ -416,7 +415,6 @@ func removeLegacyFeeRecipientFiles(c *cli.Context) error {
}

return nil

}

// Update the latest network state at each cycle
Expand Down Expand Up @@ -450,22 +448,8 @@ func GetPriorityFee(priorityFee *big.Int, maxFee *big.Int) *big.Int {
// Print a message if Saturn has been deployed yet
func printSaturnMessage(log *log.ColorLogger) {
log.Println(`
* .
* / \
* |.'.|
* |'.'|
* ,'| |'.
* |,-'-|-'-.|
* __|_| | _ _ _____ _
* | ___ \| | | | | | ___ \ | |
* | |_/ /|__ ___| | _____| |_ | |_/ /__ ___ | |
* | // _ \ / __| |/ / _ \ __| | __/ _ \ / _ \| |
* | |\ \ (_) | (__| < __/ |_ | | | (_) | (_) | |
* \_| \_\___/ \___|_|\_\___|\__| \_| \___/ \___/|_|
* +---------------------------------------------------+
* | DECENTRALISED STAKING PROTOCOL FOR ETHEREUM |
* +---------------------------------------------------+
*
* ============== Saturn 1 has launched! ===============
`)

fmt.Print(saturnArt)
}
Loading
Loading