ssbc / ssb-meta-feeds

10 stars 0 forks source link

Fix FeedDetails.equals to compare buffers correctly #107

Closed staltz closed 1 year ago

staltz commented 1 year ago

Context

I got some weird duplicate branches coming out of branchStream, and it turned out that the '.equals()' function wasn't working here:

https://github.com/ssbc/ssb-meta-feeds/blob/895781aa18d789d79600020119bb22150061ef3a/lookup.js#L134

Problem

FeedDetails's equals() is too simplistic, it's comparing two buffers with ===, and it's comparing two objects (keys) with === too.

Solution

Compare buffers with Buffer.equals and compare objects with fast-deep-equal.

1st :x: 2nd :heavy_check_mark: