mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Test
This commit is contained in:
parent
17e322cd71
commit
89ff328325
@ -16,13 +16,17 @@ const ManifestStore = async ({ ipfs, storage } = {}) => {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
storage = storage || await ComposedStorage(
|
storage = storage || await ComposedStorage(
|
||||||
await LRUStorage({ size: 1000 }),
|
await LRUStorage({ size: 100000 }),
|
||||||
await IPFSBlockStorage({ ipfs, pin: true })
|
await IPFSBlockStorage({ ipfs, pin: true })
|
||||||
)
|
)
|
||||||
|
|
||||||
const get = async (address) => {
|
const get = async (address) => {
|
||||||
const bytes = await storage.get(address)
|
const bytes = await storage.get(address)
|
||||||
const { value } = await Block.decode({ bytes, codec, hasher })
|
const { value } = await Block.decode({ bytes, codec, hasher })
|
||||||
|
if (value) {
|
||||||
|
// Write to storage to make sure it gets pinned on IPFS
|
||||||
|
await storage.put(address, bytes)
|
||||||
|
}
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +315,8 @@ const Log = async (identity, { logId, logHeads, access, entryStorage, headsStora
|
|||||||
/* 6. Add the new entry to heads (=union with current heads) */
|
/* 6. Add the new entry to heads (=union with current heads) */
|
||||||
await _heads.add(entry)
|
await _heads.add(entry)
|
||||||
|
|
||||||
|
await _entries.put(entry.hash, entry.bytes)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,13 +122,16 @@ const OrbitDB = async ({ ipfs, id, identity, identities, directory } = {}) => {
|
|||||||
if (isValidAddress(address)) {
|
if (isValidAddress(address)) {
|
||||||
// If the address given was a valid OrbitDB address, eg. '/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13'
|
// If the address given was a valid OrbitDB address, eg. '/orbitdb/zdpuAuK3BHpS7NvMBivynypqciYCuy2UW77XYBPUYRnLjnw13'
|
||||||
const addr = OrbitDBAddress(address)
|
const addr = OrbitDBAddress(address)
|
||||||
|
console.log(1)
|
||||||
manifest = await manifestStore.get(addr.hash)
|
manifest = await manifestStore.get(addr.hash)
|
||||||
const acType = manifest.accessController.split('/', 2).pop()
|
const acType = manifest.accessController.split('/', 2).pop()
|
||||||
AccessController = getAccessController(acType)()
|
AccessController = getAccessController(acType)()
|
||||||
|
console.log(2)
|
||||||
accessController = await AccessController({ orbitdb: { open, identity, ipfs }, identities, address: manifest.accessController })
|
accessController = await AccessController({ orbitdb: { open, identity, ipfs }, identities, address: manifest.accessController })
|
||||||
name = manifest.name
|
name = manifest.name
|
||||||
type = type || manifest.type
|
type = type || manifest.type
|
||||||
meta = manifest.meta
|
meta = manifest.meta
|
||||||
|
console.log(3)
|
||||||
} else {
|
} else {
|
||||||
// If the address given was not valid, eg. just the name of the database
|
// If the address given was not valid, eg. just the name of the database
|
||||||
type = type || DefaultDatabaseType
|
type = type || DefaultDatabaseType
|
||||||
@ -153,12 +156,14 @@ const OrbitDB = async ({ ipfs, id, identity, identities, directory } = {}) => {
|
|||||||
|
|
||||||
address = address.toString()
|
address = address.toString()
|
||||||
|
|
||||||
|
console.log(4)
|
||||||
const db = await Database({ ipfs, identity, address, name, access: accessController, directory, meta, syncAutomatically: sync, headsStorage, entryStorage, indexStorage, referencesCount })
|
const db = await Database({ ipfs, identity, address, name, access: accessController, directory, meta, syncAutomatically: sync, headsStorage, entryStorage, indexStorage, referencesCount })
|
||||||
|
|
||||||
db.events.on('close', onDatabaseClosed(address))
|
db.events.on('close', onDatabaseClosed(address))
|
||||||
|
|
||||||
databases[address] = db
|
databases[address] = db
|
||||||
|
|
||||||
|
console.log(5)
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user