Enforce flood threshold in retry and path-prep selection
Ensure MessageRetryService forces flood once the attempt reaches floodFromAttempt even if a selector returns null, and pass SendAttemptPlan.floodFromAttempt from preparePathForContactSend so zero-budget plans keep the saved path.
This commit is contained in:
1 parent
27cc332383
commit
723fa18b68
4 files changed
+308
-13
No files matched your search
@@ -5466,16 +5466,21 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
|
||||
Future<PathSelection> preparePathForContactSend(Contact contact) async {
|
||||
PathSelection? autoSelection;
|
||||
final autoRotationEnabled =
|
||||
_appSettingsService?.settings.autoRouteRotationEnabled == true;
|
||||
if (autoRotationEnabled && contact.pathOverride == null) {
|
||||
final directRetries =
|
||||
_appSettingsService?.settings.directRetries ??
|
||||
SendAttemptPlan.defaultDirectRetries;
|
||||
final settings = _appSettingsService?.settings;
|
||||
final plan = SendAttemptPlan(
|
||||
directRetries:
|
||||
settings?.directRetries ?? SendAttemptPlan.defaultDirectRetries,
|
||||
floodRetries:
|
||||
settings?.floodRetries ?? SendAttemptPlan.defaultFloodRetries,
|
||||
rotateRoutes:
|
||||
settings?.autoRouteRotationEnabled == true &&
|
||||
contact.pathOverride == null,
|
||||
);
|
||||
if (plan.rotateRoutes) {
|
||||
autoSelection = _selectAutoPathForAttempt(
|
||||
contact.publicKeyHex,
|
||||
attemptIndex: 0,
|
||||
directRetries: directRetries,
|
||||
directRetries: plan.floodFromAttempt ?? (1 << 30),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -330,15 +330,22 @@ class MessageRetryService extends ChangeNotifier {
|
||||
return null;
|
||||
}
|
||||
|
||||
final floodFrom = plan.floodFromAttempt;
|
||||
final recentSelections = List<PathSelection>.from(
|
||||
_attemptPathHistory[message.messageId] ?? const <PathSelection>[],
|
||||
);
|
||||
return config.selectRetryPath!(
|
||||
final selection = config.selectRetryPath!(
|
||||
contact.publicKeyHex,
|
||||
message.retryCount,
|
||||
plan.floodFromAttempt ?? (1 << 30),
|
||||
floodFrom ?? (1 << 30),
|
||||
recentSelections,
|
||||
);
|
||||
if (floodFrom != null && message.retryCount >= floodFrom) {
|
||||
return selection != null && selection.useFlood
|
||||
? selection
|
||||
: const PathSelection(pathBytes: [], hopCount: -1, useFlood: true);
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
void _recordAttemptPathHistory(String messageId, PathSelection selection) {
|
||||
|
||||
Reference in new issue
Block a user