Skip to content

Commit 35140c9

Browse files
nullunCopilot
andauthored
Apply suggestions from code review
Mostly nil reference checks, most (if not all) would be impossible to happen, but better safe than sorry. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0a32726 commit 35140c9

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func runTUI(cmd *cobra.Command, algodData string, incentivesFlag bool, version s
165165

166166
// Display Hybrid Notice on launch
167167
// Only shown if EnableP2PHybridMode is unset/false and hasn't already been set to "do not show again"
168-
hybridEnabled := m.Data.Config.EnableP2PHybridMode != nil && *m.Data.Config.EnableP2PHybridMode
168+
hybridEnabled := m.Data.Config != nil && m.Data.Config.EnableP2PHybridMode != nil && *m.Data.Config.EnableP2PHybridMode
169169
if !hybridEnabled && algodutils.ShowHybridPopUp() {
170170
p.Send(app.HybridModal)
171171
}

internal/algod/config/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ type Config struct {
77

88
// IsEqual compares two Config objects and returns true if all their fields have the same values, otherwise false.
99
func (c Config) IsEqual(conf Config) bool {
10-
return c.EnableP2PHybridMode == conf.EnableP2PHybridMode
10+
if c.EnableP2PHybridMode == nil && conf.EnableP2PHybridMode == nil {
11+
return true
12+
}
13+
if c.EnableP2PHybridMode == nil || conf.EnableP2PHybridMode == nil {
14+
return false
15+
}
16+
return *c.EnableP2PHybridMode == *conf.EnableP2PHybridMode
1117
}
1218

1319
// MergeAlgodConfigs merges two Config objects, with non-zero and non-default fields in 'b' overriding those in 'a'.

ui/modals/hybrid/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (m ViewModel) BorderColor() string {
7070

7171
// Controls returns a formatted string displaying the available control options (yes or no) with styled color representations.
7272
func (m ViewModel) Controls() string {
73-
hybridEnabled := m.State.Config.EnableP2PHybridMode != nil && *m.State.Config.EnableP2PHybridMode
73+
hybridEnabled := m.State.Config != nil && m.State.Config.EnableP2PHybridMode != nil && *m.State.Config.EnableP2PHybridMode
7474
controls := "| "
7575
if !hybridEnabled && utils.ShowHybridPopUp() {
7676
controls += style.Red.Render("(d)on't show again") + " | "

ui/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (m StatusViewModel) View() string {
9494
// Last Round
9595
row1 := lipgloss.JoinHorizontal(lipgloss.Left, beginning, middle, end)
9696

97-
if m.Data.Config.EnableP2PHybridMode != nil && *m.Data.Config.EnableP2PHybridMode {
97+
if m.Data.Config != nil && m.Data.Config.EnableP2PHybridMode != nil && *m.Data.Config.EnableP2PHybridMode {
9898
end = "P2P: " + style.Green.Render("YES") + " "
9999
} else {
100100
end = "P2P: " + style.Red.Render("NO") + " "

0 commit comments

Comments
 (0)