Skip to content

Commit e03fd74

Browse files
committed
Merge branch 'fix_data_race'
2 parents 6363081 + 88de507 commit e03fd74

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

backend/accounts/baseaccount.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type BaseAccount struct {
7070
// synced indicates whether the account has loaded and finished the initial sync of the
7171
// addresses.
7272
synced atomic.Bool
73-
offline error
73+
offline atomic.Pointer[error]
7474

7575
// notes handles transaction notes.
7676
notes *notes.Notes
@@ -128,13 +128,17 @@ func (account *BaseAccount) ResetSynced() {
128128

129129
// Offline implements Interface.
130130
func (account *BaseAccount) Offline() error {
131-
return account.offline
131+
errorPtr := account.offline.Load()
132+
if errorPtr == nil {
133+
return nil
134+
}
135+
return *errorPtr
132136
}
133137

134138
// SetOffline sets the account offline status and emits the EventStatusChanged() if the status
135139
// changed.
136140
func (account *BaseAccount) SetOffline(offline error) {
137-
account.offline = offline
141+
account.offline.Store(&offline)
138142
account.Notify(observable.Event{
139143
Subject: string(types.EventStatusChanged),
140144
Action: action.Reload,

0 commit comments

Comments
 (0)