-
Notifications
You must be signed in to change notification settings - Fork 20
Conversation
We have datastores and blockstores and blockstores are like datastores just with a different key/value types. Instead of retyping them, make datastores generic so blockstores can be a specialisation of datastores. The generics have defaults so this will be a backwards compatible change.
Bah, not quite so straight forwards: microsoft/TypeScript#29401 |
Can you explain the rationale a little more? The problems I run into with these interfaces is that they seem to be attempting to wrap many different uses into a few key concepts that don't actually have much in common. |
How did I get here. While waiting for a ts-related build to run I started swapping cids and ipld-block out for multiformats in ipfs-repo to progress the multiformats upgrade in the spirit of "How hard could it be?!".
Our notion of a Blockstore is not really defined anywhere. Their types are generated from their implementations so leak their constructors and as such the types of their dependencies - for example Phew. All the consuming code really cares about is Datastores have a dependency-free TS interface in this module which they can all implement, I figured to do the same thing for Blockstores, in the spirit of coding to the interface and not the implementation. This PR should not be merged however, with a bit more thought this is the wrong way to do this - we should have a
* = it would be nice if |
good background, thanks 👍 re ipld-block and the general concept of a "block" - this is a pattern we've been flailing on quite a bit, not quite happy with any incarnation. Even though it's One of the things I'd like to do while we're considering the foundations of the stack is revisit this and figure out better abstractions that don't tie you too tightly to dependencies to make them work, but also don't require you to have all of the pieces and forms of a "block" to make it work. It's kind of fundamental to IPFS that this is easy, but also important for JS that it doesn't require you have all the things you could possibly need to make it work. But while you're looking at this, consider multiformats/block an experiment! It's very likely that it's not the right form and needs to be tweaked, augmented, replaced, deleted. We just need more practical experience with it. So don't consider it out of bounds for change if you're seeing obvious deficiencies or better ways to achieve it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I liked how this approach ended up
We have datastores and blockstores and blockstores are like datastores just with a different key/value types.
Instead of retyping them, make datastores generic so blockstores can be a specialisation of datastores.
The generics have defaults so this will be a backwards compatible change.