Community icon indicating copy to clipboard operation
Community copied to clipboard

Comments cannot be looked up based on ID

Open karalabe opened this issue 7 years ago • 3 comments

Every comment in Akasha has a unique ID, however there doesn't seem to be any way to look up the Ethereum (Solidity) object associated with that ID.

There was a similar issue with entries too (https://github.com/AkashaProject/dapp/issues/85), but the Entries contract has a better Publish event from this perspective event Publish(address indexed author, bytes32 indexed entryId);, as the entryId is indexed, so I can filter the entire chain for it (expensive as hell, but resolvable).

However, the Comments contract has a more restricted Publish event: event Publish(address indexed author, bytes32 indexed entryId, bytes32 indexed parent, bytes32 id);, where the id is not indexed. This means that without some additional information (author, entryid or parent), there is no way to filter for a comment. Similarly there's no contract method to directly resolve a comment.

I can't say what a good solution to this would be, but similarly to my suggestion around entries, imho if you support assigning unique IDs to stuff within Akasha, those should be fully qualified and resolvable by themselves, otherwise why bother with the ID in the first place. I'm aware this requires a new set of contracts, so it's out of the question for the beta, but when you start working on contracts again, perhaps keep this in mind too.

karalabe avatar Jan 21 '18 15:01 karalabe

Indexing the id is not useful in the current flow for beta version of Akasha. We're displaying comments only for entries and profiles which are satisfied by the current event. But you're right in the future this might be helpful.

kenshyx avatar Jan 22 '18 10:01 kenshyx

Also there can be max 3 indexed params so I would have to change one of them.

kenshyx avatar Jan 22 '18 14:01 kenshyx

I guess my main concern with the filter based approach is that filtering the entire chain for events grows linearly with the size of the blockchain. So finding the comments a user made will take 10 times as much in a year than it takes now (given Akasha's ~1 month launch). Can't say how big of a problem this will be years down the line, but it may be something to keep in mind.

karalabe avatar Jan 22 '18 15:01 karalabe