sub init
{
$json = DXJSON->new;
+ $json->canonical(0);
if (check_cache()) {
$noinrush = 1;
} else {
my $respot = 0;
if ($cand && ref $cand) {
if (@$cand <= CData) {
- unless ($self->{minspottime} > 0 && $now - $cand->[CTime] >= $self->{minspottime}) {
+ if ($self->{minspottime} > 0 && $now - $cand->[CTime] < $self->{minspottime}) {
dbg("RBN: key: '$sp' call: $call qrg: $qrg DUPE \@ ". atime(int $cand->[CTime])) if $dbgrbn;
return;
}
} elsif ($cand) {
dbg("RBN: key '$sp' = '$cand' not ref");
return;
- }
-
- # here we either have an existing spot record buildup on the go, or we need to create the first one
- unless ($cand) {
+ } else {
+ # new spot / frequency
$spots->{$sp} = $cand = [$now, 0];
dbg("RBN: key: '$sp' call: $call qrg: $qrg NEW" . ($respot ? ' RESPOT' : '')) if $dbgrbn;
}
++$self->{queue}->{$sp};# unless @$cand>= CData; # queue the KEY (not the record)
- dbg("RBN: key: '$sp' ADD RECORD call: $call qrg: $qrg origin: $origin") if $dbgrbn;
+ dbg("RBN: key: '$sp' ADD RECORD call: $call qrg: $qrg origin: $origin respot: $respot") if $dbgrbn;
push @$cand, $r;
# we have a candidate, create qualitee value(s);
unless (@$cand > CData) {
dbg "RBN: QUEUE key '$sp' MISSING RECORDS, IGNORED" . dd($cand) if isdbg 'rbnqueue';
+ delete $spots->{$sp}; # don't remember it either - this means that a spot HAS to come in with sufficient spotters to be processed.
+ delete $dxchan->{queue}->{$sp};
next;
}
dbg "RBN: QUEUE PROCESSING key: '$sp' $now >= $cand->[CTime]" if isdbg 'rbnqueue';
# clear out the data and make this now just "spotted", but no further action required until respot time
dbg "RBN: QUEUE key '$sp' cleared" if isdbg 'rbn';
- delete $spots->{$sp};
delete $dxchan->{queue}->{$sp};
# calculate new sp (which will be 70% likely the same as the old one)
my $nsp = "$r->[RCall]|$nqrg";
if ($sp ne $nsp) {
dbg("RBN:SKIM CHANGE KEY sp '$sp' -> '$nsp' for storage") if $rbnskim;
+ delete $spots->{$sp};
$spots->{$nsp} = [$now, $cand->[CQual]];
+ } else {
+ $spots->{$sp} = [$now, $cand->[CQual]];
}
}
else {
sub write_cache
{
my $ta = [ gettimeofday ];
- $json->indent(1) if isdbg 'rbncache';
+ $json->indent(1)->canonical(1) if isdbg 'rbncache';
my $s = eval {$json->encode($spots)};
if ($s) {
my $fh = IO::File->new(">$cachefn") or confess("writing $cachefn $!");
$fh->close;
} else {
dbg("RBN:Write_cache error '$@'");
+ return;
}
- $json->indent(0);
+ $json->indent(0)->canonical(0);
my $diff = _diffms($ta);
- dbg("RBN:WRITE_CACHE time to write: $diff mS");
+ my $size = sprintf('%.3fKB', (length($s) / 1000));
+ dbg("RBN:WRITE_CACHE size: $size time to write: $diff mS");
}
sub check_cache