lib/connections: Slightly refactor limiter juggling
Two small behavior changes: don't "charge" the data to the global rate limit until it's been accepted by the device specific limiter, and fix the send/recv direction in the log print on per device rate limits.
This commit is contained in:
@@ -377,6 +377,15 @@ func (cfg *Configuration) clean() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeviceMap returns a map of device ID to device configuration for the given configuration.
|
||||
func (cfg *Configuration) DeviceMap() map[protocol.DeviceID]DeviceConfiguration {
|
||||
m := make(map[protocol.DeviceID]DeviceConfiguration, len(cfg.Devices))
|
||||
for _, dev := range cfg.Devices {
|
||||
m[dev.DeviceID] = dev
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func convertV27V28(cfg *Configuration) {
|
||||
// Show a notification about enabling filesystem watching
|
||||
cfg.Options.UnackedNotificationIDs = append(cfg.Options.UnackedNotificationIDs, "fsWatcherNotification")
|
||||
@@ -797,12 +806,3 @@ func filterURLSchemePrefix(addrs []string, prefix string) []string {
|
||||
}
|
||||
return addrs
|
||||
}
|
||||
|
||||
// mapDeviceConfigs returns a map of device ID to device configuration for the given configuration.
|
||||
func (cfg *Configuration) DeviceMap() map[protocol.DeviceID]DeviceConfiguration {
|
||||
m := make(map[protocol.DeviceID]DeviceConfiguration, len(cfg.Devices))
|
||||
for _, dev := range cfg.Devices {
|
||||
m[dev.DeviceID] = dev
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user