remove prefix matching for ids and authors filter fields

- this also fixes https://github.com/hoytech/strfry/issues/109
This commit is contained in:
Doug Hoyte
2024-08-30 15:56:41 -04:00
parent 80249f2078
commit 21d4e07b87
9 changed files with 42 additions and 70 deletions

View File

@ -89,7 +89,9 @@ c1e5e04d92d9bd20701bff4cbdac1cdc317d405035883b7adcf9a6a5308d0f54
my $topics = [qw{
bitcoin
nos
nostr
nostrnovember
gitlog
introductions
jb55
@ -111,14 +113,14 @@ sub genRandomFilterGroup {
if (rand() < .15) {
$f->{ids} = [];
for (1..(rand()*10)) {
push @{$f->{ids}}, randPrefix($ids->[int(rand() * @$ids)], $useLimit);
push @{$f->{ids}}, $ids->[int(rand() * @$ids)];
}
}
if (rand() < .3) {
$f->{authors} = [];
for (1..(rand()*5)) {
push @{$f->{authors}}, randPrefix($pubkeys->[int(rand() * @$pubkeys)], $useLimit);
push @{$f->{authors}}, $pubkeys->[int(rand() * @$pubkeys)];
}
}
@ -174,13 +176,6 @@ sub genRandomFilterGroup {
return \@filters;
}
sub randPrefix {
my $v = shift;
my $noPrefix = shift;
return $v if $noPrefix || rand() < .5;
return substr($v, 0, (int(rand() * 20) + 1) * 2);
}
sub genRandomMonitorCmds {
my $nextConnId = 1;
my @out;
@ -236,6 +231,13 @@ sub testMonitor {
my $fge = encode_json($interestFg);
print "filt: $fge\n\n";
# HACK for debugging:
#$fge = q{[{"#t":["nostrnovember","nostr"]}]};
#$monCmds = [
# ["sub",1000000,"mysub",decode_json($fge)],
# ["interest",1000000,"mysub"],
#];
print "DOING MONS\n";
my $pid = open2(my $outfile, my $infile, './strfry monitor | jq -r .id | sort | sha256sum');
for my $c (@$monCmds) { print $infile encode_json($c), "\n"; }