ssbc / ssb-tangle

8 stars 2 forks source link

getHeads should do deduplication #7

Closed Powersource closed 4 years ago

Powersource commented 4 years ago

Here's my map

{
      '%QvMC8ErhfGpfThrxxpJ2M2FT5GJ8E5A74813Fe9MRCQ=.sha256': { '%YGUpnLZ5WF9QUcQyDv3qn8UImUK/mf1pf/ToqihLrSo=.sha256': 1 },
      '%YGUpnLZ5WF9QUcQyDv3qn8UImUK/mf1pf/ToqihLrSo=.sha256': {
        '%q05AUdw3PeWZ7bAMR2mxBKo6Ttz9DgvCukq9Nc73dxk=.sha256': 1,
        '%QaGyRlbX8s3pzmsWN0sqmMiJhUmuNXijTdUuhNPI5x0=.sha256': 1
      },
      '%QaGyRlbX8s3pzmsWN0sqmMiJhUmuNXijTdUuhNPI5x0=.sha256': { '%b/q1KPqRN45/5Kfakw7zz0TndBQGKZUpvYRAN4dVtGk=.sha256': 1 },
      '%q05AUdw3PeWZ7bAMR2mxBKo6Ttz9DgvCukq9Nc73dxk=.sha256': { '%b/q1KPqRN45/5Kfakw7zz0TndBQGKZUpvYRAN4dVtGk=.sha256': 1 }
    }

here's the output of getHeads

    [
      '%b/q1KPqRN45/5Kfakw7zz0TndBQGKZUpvYRAN4dVtGk=.sha256',
      '%b/q1KPqRN45/5Kfakw7zz0TndBQGKZUpvYRAN4dVtGk=.sha256'
    ]

I think users of the api probably expect keys to only occur once in the returned list.

mixmix commented 4 years ago

great catch! we should add a test around this case then have it pass. (it's been a while since I wrote that part of the code so I'd need tests to fix it well myself)

I'm honoured you've been reading and using this code so closely, and writing such great issues. Thanks @Powersource

mixmix commented 4 years ago

I think this is resolved now