[RAD] I'm completely lost...
The title says everything: I'm completely lost...
I added RAD to my browser as mentioned in the docs and continued evaluating GUN - until I saw that there were only two keys in my "IndexedDB": namely "%1C" and "!"
So I started evaluating RAD using a trivialRADStore:
const trivialRADStore_Store = Object.create(null)
const trivialRADStore = {
get: function (Key, Callback) {
console.log(' trivialRADStore: reading', Key)
return Callback(null,trivialRADStore_Store['' + Key])
},
put: function (Key, Data, Callback) {
console.log(' trivialRADStore: writing', Key, '(' + typeof Data + ')')
trivialRADStore_Store['' + Key] = Data
return Callback(null,1)
}
}which I could directly write to:
const Rad = window.Radisk({ store:trivialRADStore })
async function RAD_read (Key, Options) {
return new Promise((resolve,reject) => {
Rad(Key, (Error, Data, Info) => {
console.log(' RAD Info:', Info)
return (
Error == null ? resolve(Data) : reject(Error)
)
}, Options)
})
}
async function RAD_write (Key, Data) {
return new Promise((resolve,reject) => {
Rad(Key, Data, (Error, Data) => {
return (
Error == null ? resolve(Data) : reject(Error)
)
})
})
}Surprisingly, my RAD adapter was also called with two keys only (the same as above). (However, I also logged the "info" record returned by the "read" variant of the RAD function - and that sometimes reported it would have parsed "1048576" bytes/chars although I had not written much at that point....)
Then I had the idea that I might have written too few keys and too little data - hence I wrote a simple function to fill my store
async function writeNested (BaseKey,Depth) {
for (let i = 0; i < 10; i++) {
const currentKey = (BaseKey === '' ? '' : BaseKey + '/') + i
await RAD_write(currentKey,currentKey)
if (Depth > 1) { await writeNested(currentKey,Depth-1) }
}
}and that soon started to take looooong to write a new entry - and had to be stopped after very few write calls (it was invoked with n = 3 - for 1110 entries - but did not come far...).
So: what am I doing wrong? Where is the "radix tree" promised by the docs?
Source: amark/gun