Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jun 11, 2024
1 parent 74cba69 commit 2965e2a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@
// "-w=${workspaceFolder}/.nodes/bsn-1/bsnn",
]
},
{
"name": "Init network",
"presentation": {
"group": "20-Run"
},
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/accumulated",
"args": [
"init",
"network",
"-w=${workspaceFolder}/.nodes/fozzie",
"${workspaceFolder}/.genesis/fozzie/private.yaml",
"${workspaceFolder}/.genesis/fozzie/network.json",
]
},
// Services
{
"name": "API (mainnet)",
Expand Down
4 changes: 1 addition & 3 deletions cmd/accumulated/cmd_init_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,12 @@ func initNetwork(cmd *cobra.Command, args []string) {
cfg.P2P.Key = &run.RawPrivateKey{Address: addr.String()}

// Configure the validator
cvc := new(run.CoreValidatorConfiguration)
cvc := run.AddConfiguration(cfg, new(run.CoreValidatorConfiguration), nil)
cfg.Configurations = []run.Configuration{cvc}
cvc.Listen = node.Listen().Scheme("tcp").Directory().TendermintP2P().Multiaddr()
cvc.BVN = bvn.Id
cvc.BvnBootstrapPeers = bvn.Peers(node).Scheme("tcp").BlockValidator().TendermintP2P().WithKey().Multiaddr()
cvc.DnBootstrapPeers = network.Peers(node).Scheme("tcp").Directory().TendermintP2P().WithKey().Multiaddr()
cvc.EnableHealing = run.Ptr(false)
cvc.EnableSnapshots = run.Ptr(false)

// Configure the validator key
addr = address.FromED25519PrivateKey(node.PrivValKey)
Expand Down
20 changes: 20 additions & 0 deletions cmd/accumulated/run/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,23 @@ func peersForDumbDialer(entries []*HttpPeerMapEntry) map[string][]peer.AddrInfo
}
return m
}

func HaveConfiguration[T any](cfg *Config, predicate func(T) bool, existing *T) bool {
for _, s := range cfg.Configurations {
t, ok := s.(T)
if ok && (predicate == nil || predicate(t)) {
if existing != nil {
*existing = t
}
return true
}
}
return false
}

func AddConfiguration[T Configuration](cfg *Config, s T, predicate func(T) bool) T {
if !HaveConfiguration(cfg, predicate, &s) {
cfg.Configurations = append(cfg.Configurations, s)
}
return s
}

0 comments on commit 2965e2a

Please sign in to comment.