Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a380c3

Browse files
committedMar 21, 2025··
backend/bitbox02bootloader: remove old-school statusChanged event
1 parent c0952e3 commit 4a380c3

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed
 

‎backend/devices/bitbox02bootloader/device.go

+7-23
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,13 @@ type Device struct {
4242
bootloader.Device
4343
deviceID string
4444

45-
mu sync.RWMutex
46-
onEvent func(event.Event, interface{})
45+
mu sync.RWMutex
4746

4847
log *logrus.Entry
4948

5049
observable.Implementation
5150
}
5251

53-
// EventStatusChanged is fired when the status changes. Check the status using Status().
54-
const EventStatusChanged event.Event = "statusChanged"
55-
5652
// NewDevice creates a new instance of Device.
5753
func NewDevice(
5854
deviceID string,
@@ -134,26 +130,14 @@ func (device *Device) Keystore() keystoreInterface.Keystore {
134130

135131
// SetOnEvent implements device.Device.
136132
func (device *Device) SetOnEvent(onEvent func(event.Event, interface{})) {
137-
device.mu.Lock()
138-
defer device.mu.Unlock()
139-
device.onEvent = onEvent
140133
}
141134

142135
func (device *Device) fireEvent() {
143-
device.mu.RLock()
144-
f := device.onEvent
145-
device.mu.RUnlock()
146-
if f != nil {
147-
// Old-school
148-
f(EventStatusChanged, nil)
149-
150-
// New-school
151-
device.Notify(observable.Event{
152-
Subject: fmt.Sprintf("status"),
153-
Action: action.Replace,
154-
Object: device.Status(),
155-
})
156-
}
136+
device.Notify(observable.Event{
137+
Subject: fmt.Sprintf("status"),
138+
Action: action.Replace,
139+
Object: device.Status(),
140+
})
157141
}
158142

159143
// firmwareBootRequired returns true if the currently flashed firmware has to be booted/run before
@@ -269,7 +253,7 @@ func (device *Device) VersionInfo() (*VersionInfo, error) {
269253
brokenInstall := latestFirmwareVersion == currentFirmwareVersion &&
270254
!bytes.Equal(currentFirmwareHash, latestFirmwareHash)
271255

272-
canUpgrade := erased || latestFirmwareVersion > currentFirmwareVersion || brokenInstall || true
256+
canUpgrade := erased || latestFirmwareVersion > currentFirmwareVersion || brokenInstall
273257
additionalUpgradeFollows := nextFw.monotonicVersion < latestFirmwareVersion
274258
device.log.
275259
WithField("latestFirmwareVersion", latestFirmwareVersion).

0 commit comments

Comments
 (0)
Please sign in to comment.