-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathstep-checkpoint-sync.go
More file actions
75 lines (63 loc) · 2.4 KB
/
step-checkpoint-sync.go
File metadata and controls
75 lines (63 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package config
import (
"fmt"
"github.com/rocket-pool/smartnode/shared/services/config"
cfgtypes "github.com/rocket-pool/smartnode/shared/types/config"
)
func createCheckpointSyncStep(wiz *wizard, currentStep int, totalSteps int) *textBoxWizardStep {
// Create the labels and args
checkpointSyncLabel := wiz.md.Config.ConsensusCommon.CheckpointSyncProvider.Name
helperText := "Your client supports Checkpoint Sync. This powerful feature allows it to copy the most recent state from a separate Consensus client that you trust, so you don't have to wait for it to sync from scratch - you can start using it instantly!\n\nTake a look at our documentation for an example of how to use it:\nhttps://docs.rocketpool.net/node-staking/config-docker#beacon-chain-checkpoint-syncing\n\nIf you would like to use Checkpoint Sync, please provide the provider URL here. If you don't want to use it, leave it blank."
show := func(modal *textBoxModalLayout) {
wiz.md.setPage(modal.page)
modal.focus()
for label, box := range modal.textboxes {
for _, param := range wiz.md.Config.ConsensusCommon.GetParameters() {
if param.Name == label {
box.SetText(fmt.Sprint(param.Value))
}
}
}
}
done := func(text map[string]string) {
wiz.md.Config.ConsensusCommon.CheckpointSyncProvider.Value = text[checkpointSyncLabel]
// Get the selected client
client, err := wiz.md.Config.GetSelectedConsensusClientConfig()
if err != nil {
wiz.md.app.Stop()
fmt.Printf("Error setting the consensus client checkpoint sync provider: %s", err.Error())
}
// Check to see if it supports doppelganger detection
unsupportedParams := client.(cfgtypes.LocalConsensusConfig).GetUnsupportedCommonParams()
supportsDoppelganger := true
for _, param := range unsupportedParams {
if param == config.DoppelgangerDetectionID {
supportsDoppelganger = false
}
}
// Move to the next appropriate dialog
if supportsDoppelganger {
wiz.doppelgangerDetectionModal.show()
} else {
wiz.useFallbackModal.show()
}
}
back := func() {
wiz.graffitiModal.show()
}
return newTextBoxWizardStep(
wiz,
currentStep,
totalSteps,
helperText,
76,
"Consensus Client > Checkpoint Sync",
[]string{checkpointSyncLabel},
[]int{wiz.md.Config.ConsensusCommon.CheckpointSyncProvider.MaxLength},
[]string{wiz.md.Config.ConsensusCommon.CheckpointSyncProvider.Regex},
show,
done,
back,
"step-checkpoint-sync",
)
}