Repository navigation
feat: with_recasts flag on the following feed - #40
Conversation
/v2/farcaster/feed/following (and /v2/farcaster/feed?feed_type=following) take with_recasts=true. Followed users' recasts are then merged in at the time of the recast, each cast shows once (its newest entry), and the item carries a hydrated `recaster` user. Without the flag the feed is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Low compatibility risk because it's opt-in, but potentially significant performance impact for busy nodes. Should we setup performance benchmarks? |
|
Ran benchmarks. Setup: the real hub service on RocksDB (the
(ranges are two separate runs)
If that's still too much for busy nodes, two cheap options: fetch recasts with a smaller page size than casts (most accounts recast less than they cast), or put the flag behind a node config switch so operators can turn it off. Happy to add either. Benchmark code (local only, not in this PR: it needs
|
Signed-off-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com>
The following feed only merges followed users' own casts, so recasts never show up. Clients that want a retweet-style timeline have no way to build one: they'd have to call
reactionsByFidonce per followed account.This adds
with_recasts=trueto/v2/farcaster/feed/followingand to/v2/farcaster/feed?feed_type=following. Without the flag, the feed is unchanged.With the flag:
get_reactions_by_fid(type Recast, newest first, same page size). This happens in the same per-account task asget_casts_by_fidand goes into the same timestamp heap.get_cast) only for the items on the page. A cast that has since been deleted is skipped.recasterfield onCast. The field is left out of the JSON when it's empty, so other endpoints don't change.Cost: with the flag, a page makes twice as many hub reads (one more per followed account), plus one
get_castper recast shown.Tests:
test_recasts_merge_newest_first_oncecovers the entry mapping (cast adds and recasts in, likes out) and dedupe and ordering intake_newest.cargo test --lib api::passes (300 tests). I haven't run it on a synced node.Separate issue I noticed while reading this code, not changed here:
max_following_fetch(1000) takes the first 1000 followed accounts in key order, which means the 1000 lowest FIDs. Someone following 17k accounts never sees casts from the other 16k.