Remove mem-store utils as obsolete

This commit is contained in:
haad 2023-01-16 15:12:59 +02:00
parent 3ac87bb9a8
commit d840a46b94
2 changed files with 1 additions and 47 deletions

View File

@ -1,8 +1,8 @@
// TODO: these should be replace with orbit-db-test-utils
export { default as config } from './config.js'
export { testAPIs } from './test-apis.js'
export { default as startIpfs } from './start-ipfs.js'
export { default as stopIpfs } from './stop-ipfs.js'
export { default as waitForPeers } from './wait-for-peers.js'
export { default as connectPeers } from './connect-peers.js'
export { default as MemStore } from './mem-store.js'
export { default as CustomTestKeystore } from './custom-test-keystore.js'

View File

@ -1,46 +0,0 @@
import multihashing from 'multihashing-async'
import mh from 'multihashes'
const defaultHashAlg = 'sha2-256'
const createMultihash = (data, hashAlg) => {
return new Promise((resolve, reject) => {
multihashing(data, hashAlg || defaultHashAlg, (err, multihash) => {
if (err) { return reject(err) }
resolve(mh.toB58String(multihash))
})
})
}
export default class MemStore {
constructor () {
this._store = {}
}
async put (value) {
const data = value
const hash = await createMultihash(data)
if (!this._store) this._store = {}
this._store[hash] = data
return {
toJSON: () => {
return {
data: value,
multihash: hash
}
}
}
}
async get (key) {
return {
toJSON: () => {
return {
data: this._store[key],
multihash: key
}
}
}
}
}