Closed staltz closed 1 year ago
I got some weird duplicate branches coming out of branchStream, and it turned out that the '.equals()' function wasn't working here:
branchStream
https://github.com/ssbc/ssb-meta-feeds/blob/895781aa18d789d79600020119bb22150061ef3a/lookup.js#L134
FeedDetails's equals() is too simplistic, it's comparing two buffers with ===, and it's comparing two objects (keys) with === too.
FeedDetails
equals()
===
keys
Compare buffers with Buffer.equals and compare objects with fast-deep-equal.
Buffer.equals
1st :x: 2nd :heavy_check_mark:
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
'sequals()
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: