mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Remove mem-store utils as obsolete
This commit is contained in:
parent
3ac87bb9a8
commit
d840a46b94
@ -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'
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user