remove dead Architecture B code (topic bloom, filter_table, peer_filters)
This commit is contained in:
parent
f680931c8c
commit
d63e0c19be
3 changed files with 6 additions and 372 deletions
|
|
@ -190,12 +190,10 @@ class ForumHandlers:
|
|||
topics = self._get_subscribed_topics()
|
||||
topics_str = ", ".join(topics) if topics else "everything"
|
||||
peer_count = len(self.fdb.get_synced_instances())
|
||||
filter_count = self.fdb.get_peer_filter_count()
|
||||
return (
|
||||
f'<div style="font-size:0.85rem;color:#606060">'
|
||||
f'subscribed: {esc(topics_str)}'
|
||||
f' · {peer_count} peers'
|
||||
f' · {filter_count} filters'
|
||||
f'</div>'
|
||||
)
|
||||
|
||||
|
|
@ -841,79 +839,24 @@ class ForumHandlers:
|
|||
incoming_threads = data.get("threads", [])
|
||||
incoming_posts = data.get("posts", [])
|
||||
incoming_upvotes = data.get("upvotes", [])
|
||||
peer_topics = data.get("my_topics", [])
|
||||
peer_tag_cloud = data.get("my_tag_cloud", [])
|
||||
peer_bloom_data = data.get("content_bloom")
|
||||
peer_tag_bloom_data = data.get("tag_bloom")
|
||||
peer_filter_table = data.get("filter_table", {})
|
||||
scoped_query_tag = data.get("scoped_query", "")
|
||||
|
||||
blocked = self._blocked_instances()
|
||||
my_topics = self._get_subscribed_topics()
|
||||
from_hash = data.get("from_hash", "")
|
||||
|
||||
# Store peer's tag bloom filter (Architecture B discovery)
|
||||
if peer_tag_bloom_data and from_hash:
|
||||
self.fdb.store_peer_filter(
|
||||
peer_hash=from_hash,
|
||||
bloom_bytes=bytes(peer_tag_bloom_data),
|
||||
bloom_size=data.get("tag_bloom_size", 2048),
|
||||
bloom_hashes=data.get("tag_bloom_hashes", 3),
|
||||
tag_count=len(peer_topics),
|
||||
)
|
||||
|
||||
# Merge filter table gossip (transitive peer discovery)
|
||||
if peer_filter_table and from_hash:
|
||||
for ph, entry in peer_filter_table.items():
|
||||
if isinstance(entry, dict):
|
||||
bb = entry.get("bloom_bytes")
|
||||
if bb:
|
||||
self.fdb.store_peer_filter(
|
||||
peer_hash=ph,
|
||||
bloom_bytes=bytes(bb) if isinstance(bb, list) else bb,
|
||||
bloom_size=entry.get("bloom_size", 2048),
|
||||
bloom_hashes=entry.get("bloom_hashes", 3),
|
||||
tag_count=entry.get("tag_count", 0),
|
||||
)
|
||||
|
||||
# Handle scoped query: find peers whose bloom might contain the queried tag
|
||||
scoped_query_results = []
|
||||
if scoped_query_tag and from_hash:
|
||||
scoped_query_results = self.fdb.get_filtered_peers_by_tag(scoped_query_tag)
|
||||
|
||||
# Merge trust gossip from requester
|
||||
if from_hash:
|
||||
self.sync._merge_trust_gossip(data.get("trust_list", []), from_hash)
|
||||
|
||||
# Store peer's topics for future routing (backward compat)
|
||||
if peer_topics and from_hash:
|
||||
self.fdb.set_setting(f"peer_topics_{from_hash}", ",".join(peer_topics))
|
||||
if peer_tag_cloud and from_hash:
|
||||
self.fdb.set_setting(f"peer_tag_cloud_{from_hash}", json.dumps(peer_tag_cloud))
|
||||
|
||||
# Build our tag bloom filter to send back
|
||||
peer_tag_bs = data.get("tag_bloom_size", 2048)
|
||||
peer_tag_bh = data.get("tag_bloom_hashes", 3)
|
||||
my_tag_bloom = BloomFilter.from_tags(my_topics or [], peer_tag_bs, peer_tag_bh)
|
||||
|
||||
# Build our content bloom filter for dedup
|
||||
our_existing = set()
|
||||
peer_topics = data.get("my_topics", [])
|
||||
for t in self.fdb.get_threads_by_topics(peer_topics) if peer_topics else []:
|
||||
our_existing.add(t["id"])
|
||||
our_bloom = BloomFilter.from_items(list(our_existing), data.get("bloom_size", 2048) if data else 2048, data.get("bloom_hashes", 3) if data else 3)
|
||||
|
||||
# Build filter table gossip from our stored filters
|
||||
all_filters = self.fdb.get_all_filters()
|
||||
filter_table_gossip = {}
|
||||
for f in all_filters[:20]:
|
||||
if f["peer_hash"] != from_hash:
|
||||
filter_table_gossip[f["peer_hash"]] = {
|
||||
"bloom_bytes": list(f["bloom_bytes"]),
|
||||
"bloom_size": f["bloom_size"],
|
||||
"bloom_hashes": f["bloom_hashes"],
|
||||
"tag_count": f["tag_count"],
|
||||
}
|
||||
|
||||
# Parse peer's content bloom for dedup
|
||||
peer_bloom = None
|
||||
if peer_bloom_data:
|
||||
|
|
@ -975,8 +918,6 @@ class ForumHandlers:
|
|||
|
||||
my_blocks = list(blocked)
|
||||
my_peer_blocks = self.fdb.get_peer_block_list()
|
||||
my_tag_cloud = self.fdb.get_tag_cloud(50)
|
||||
my_tag_list = [t for t, _ in my_tag_cloud]
|
||||
|
||||
threads, posts, upvote_threads = [], [], []
|
||||
if since:
|
||||
|
|
@ -1001,11 +942,6 @@ class ForumHandlers:
|
|||
posts = [p for p in posts if p.get("thread_id") in thread_ids]
|
||||
|
||||
known_peers = [h for h in self.fdb.get_all_known_hashes() if h != from_hash]
|
||||
peer_topics_map = {}
|
||||
for ph in known_peers[:100]:
|
||||
pt = self.fdb.get_setting(f"peer_topics_{ph}", "")
|
||||
if pt:
|
||||
peer_topics_map[ph] = [t.strip() for t in pt.split(",") if t.strip()]
|
||||
|
||||
retracted = [{"id": cid, "type": ct, "author": ai, "at": ra}
|
||||
for cid, ct, ai, ra in self.fdb.get_raw_retractions()]
|
||||
|
|
@ -1020,19 +956,10 @@ class ForumHandlers:
|
|||
"blocks": {"mine": my_blocks, "peers": my_peer_blocks},
|
||||
"retractions": retracted,
|
||||
"known_peers": known_peers,
|
||||
"peer_topics": my_tag_list,
|
||||
"peer_tag_cloud": my_tag_cloud,
|
||||
"content_bloom": list(our_bloom.bytes),
|
||||
"bloom_size": data.get("bloom_size", 2048),
|
||||
"bloom_hashes": data.get("bloom_hashes", 3),
|
||||
"peer_topics_map": peer_topics_map,
|
||||
# Architecture B additions
|
||||
"tag_bloom": list(my_tag_bloom.bytes),
|
||||
"tag_bloom_size": peer_tag_bs,
|
||||
"tag_bloom_hashes": peer_tag_bh,
|
||||
"filter_table": filter_table_gossip,
|
||||
"trust_list": self.fdb.get_all_trusted_hashes(),
|
||||
"scoped_query_results": scoped_query_results,
|
||||
}),
|
||||
"headers": {},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue