Skip to content

Commit

Permalink
problem: replied event not added to bloom filter
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Apr 21, 2024
1 parent 737d702 commit a3517c7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/lib/snort_workers/master_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ workerDataStore.subscribe((data) => {
let fed = new FrontendData();
fed.baseFollows = data.ourFollows;
let roots: NostrEvent[] = [];
let inBloom:string[] = []
for (let r of data.roots) {
if (!data.ourBloom.test(r)) {
let re = data.events.get(r);
Expand All @@ -39,6 +40,7 @@ workerDataStore.subscribe((data) => {
}
roots.push(re!);
} else {
inBloom.push(r)
//console.log(42)
}
}
Expand All @@ -59,6 +61,8 @@ workerDataStore.subscribe((data) => {
fed.replies = data.replies;
fed.events = data.events;
fed._bloomString = JSON.stringify([].slice.call(data.ourBloom.buckets))
let testbloom = new BloomFilter(JSON.parse(fed._bloomString), 32)
//console.log(data.ourBloom.test(inBloom[0]), testbloom.test(inBloom[0]))
fed.ourBloom = data.ourBloom;//new BloomFilter(JSON.parse(fed._bloomString), 32)
postMessage(fed);
end()
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snort_workers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class tagSplits {
unlabelled: Set<string>;
unknown: Set<string>;
All(): Set<string> {
return new Set(...this.roots, this.replies, this.mentions, this.unlabelled, this.unknown);
return new Set([...this.roots, ...this.replies, ...this.mentions, ...this.unlabelled, ...this.unknown]);
}
constructor(event: NostrEvent) {
this.rawEvent = event;
Expand Down
26 changes: 17 additions & 9 deletions src/lib/views/messages/Messages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,24 @@
><br />
LOGGED IN AS: {$currentUser?.pubkey} <br />
<Input bind:value={eventID} class="w-64" /><Button onClick={()=>{
//let bloom = new BloomFilter(JSON.parse($FrontendDataStore._bloomString), 32)
console.log($FrontendDataStore.ourBloom)
if ($FrontendDataStore.ourBloom) {
console.log(210)
console.log(eventID)
$FrontendDataStore.ourBloom.add("t")
let result = $FrontendDataStore.ourBloom.test(eventID)
console.log(213)
console.log(214, result)
let bloom = new BloomFilter(32 * 256, 32)
bloom.add("12345")
console.log(bloom.test("12345"))
let testbloom = new BloomFilter(JSON.parse($FrontendDataStore._bloomString), 32)
console.log(testbloom)
for (let e of $stableShortList) {
console.log(testbloom.test(e.id))
}
console.log(216, testbloom.test(eventID))
// console.log($FrontendDataStore.ourBloom)
// if ($FrontendDataStore.ourBloom) {
// console.log(210)
// console.log(eventID)
// $FrontendDataStore.ourBloom.add("t")
// let result = $FrontendDataStore.ourBloom.test(eventID)
// console.log(213)
// console.log(214, result)
// }
}}>Check if event is in bloom filter</Button><br />
{$FrontendDataStore.ourBloom?.buckets.byteLength}
</div>
Expand Down

0 comments on commit a3517c7

Please sign in to comment.