- # if we are still a PC11, save it for a better offer
- if ($pcno == 11) {
- $pc11_saved = [$key, $self, $pcno, $line, $origin, $pc];
- $pc11_saved_time = $main::systime;
- dbg("saved new PC11 spot $key for a better offer") if isdbg("pc11");
- return;
- } else {
- dbg("PC61 spot $key passed onward") if isdbg("pc11");
+ # If we have an ip address we can promote by route
+ if ($rug && $rug->ip) {
+ $pcno = 61;
+ $pc->[0] = 'PC61';
+ my $hops = $pc->[8];
+ $pc->[8] = $spot[14] = $rug->ip;
+ ++$rpc11_to_61;
+ my $percent = $pc11_rx ? $rpc11_to_61 * 100 / $pc11_rx : 0;
+ dbg(sprintf("PROMOTED $self->{call}: ROUTE pc11 $key PROMOTED to pc61 with IP $spot[14] pc61: $pc61_rx pc11: $pc11_rx route->pc61 $rpc11_to_61 (%0.1f%%)", $percent)) if isdbg("pc11");
+ $line = join '^', @$pc, $hops, '~';
+
+ # update the stats (NOTE, thie record was a PC11, it has now become a PC61
+ # this is NOT the same choosing a better PC61, that is a separate record.
+ ++$pc11_rx; # 'cos we received as a PC11 it and it won't be a pc11 anymore
+ --$pc61_rx; # 'cos we'll increment it later as it's now a pc61, no double counting
+
+# dbg("CHANGED saved key: $key PC11 line to $line") if isdbg('pc11');
+ delete $pc11_saved{$key};
+ }
+
+ # if it is STILL (despite all efforts to change it) a PC11
+ # save it and wait - it will be called from pc11_process
+ if ($pcno == 11) {
+ $pc11_saved{$key} = [$main::systime, $self, $pcno, $line, $origin, $pc];
+ dbg("WAITING $self->{call}: NEW $pc->[0] spot $key waiting for a better offer") if isdbg("pc11");
+ return;
+ }