Closed DougAnderson444 closed 4 years ago
@DougAnderson444 Yeah your example just needs a small change:
const store1 = new Corestore(ram)
const trie1 = new MountableHypertrie(store1)
const trie2 = new MountableHypertrie(store1.namespace('trie2'))
...
The idea here is that every corestore has a default hypercore (which is accessed using store.default()
) -- the general pattern is to use this default core to bootstrap other cores (by storing keys directly in the core like we do in hyperdrive, for example).
MountableHypertrie
always calls default
on the corestore it's given, so if you want to reuse the same corestore you need to create a NamespacedCorestore
(which will wrap the default
method and use a different key).
Sorry for the confusion! We've only recently converged on this API.
No worries! That works like a charm :) Can't wait to use this!
@andrewosh Are the tries supposed to get the same key? I was expecting them to have 2 different keys...
https://repl.it/@DougAnderson444/HyperTrieKeyTest1
I tried to make them have 2 separate stores, but that didn't work out so well.