orbitdb-archive / orbit-db-counterstore

Counters database for OrbitDB
MIT License
10 stars 8 forks source link

Fix counter IDs and merges #44

Closed haadcode closed 2 years ago

haadcode commented 3 years ago

This PR will change the counter store and index to use identity.id as the counter ID and thus fixes merging counters.

Before this PR, the counter ID (ie. database ID) and the user ID (ie. writer ID) got mixed up resulting in mangled state where, while having correct data from updates/writes, contained also a counter for the database ID. This isn't supposed to be the case and counters should only contains pairs of (writerID, value).

This PR also changes the CounterStore to use identity.id instead of identity.publicKey as the writer's ID. This makes the ID length shorter, from 047bf7a74b85cc51a2080dac60dc6e1734343c73bc5c1c03ee68a2104f97e3fd8981833892f96110a281cd0ebf50e7cd32ffe93142b3dd238aaaba3c2903010a55 to 025a8e1ac19907f097cae707e7527cea9f46fc62af171def339a3174f663cb6ddc which will save bytes in the underlying data format (and replication/transfer bytes).

Not sure if this is backwards compatible (because of the key change). If not, we can drop the change of publicKey->id from the PR.

haadcode commented 3 years ago

I reverted the change for the IDs as I'm uncertain of backwards compatibility.

haadcode commented 3 years ago

This PR is ready for review!

This PR is required by https://github.com/orbitdb/orbit-db/pull/933

haadcode commented 2 years ago

Merged.

Thank you @tabcat for your review and improvement suggestions! 🙏 ❤️

haadcode commented 2 years ago

Published as v1.12.1 in npm