fix browser examples

This commit is contained in:
anders
2020-12-09 18:42:27 -06:00
committed by Mark Robert Henderson
parent aafa7e3483
commit 2ca2604474
4 changed files with 17 additions and 15 deletions

View File

@@ -22,7 +22,7 @@ function handleError(e) {
statusElm.innerHTML = e.message
}
const main = (IPFS, ORBITDB) => {
const main = async (IPFS, ORBITDB) => {
let orbitdb, db
let count = 0
let interval = Math.floor((Math.random() * 300) + (Math.random() * 2000))
@@ -45,7 +45,7 @@ const main = (IPFS, ORBITDB) => {
statusElm.innerHTML = "Starting IPFS..."
// Create IPFS instance
const ipfs = new Ipfs({
const ipfs = await Ipfs.create({
repo: '/orbitdb/examples/browser/new/ipfs/0.33.1',
start: true,
preload: {
@@ -59,21 +59,23 @@ const main = (IPFS, ORBITDB) => {
Swarm: [
// Use IPFS dev signal server
// '/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star',
'/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star',
// '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star',
// Use IPFS dev webrtc signal server
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star/',
'/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star/',
'/dns4/webrtc-star.discovery.libp2p.io/tcp/443/wss/p2p-webrtc-star/',
// Use local signal server
// '/ip4/0.0.0.0/tcp/9090/wss/p2p-webrtc-star',
]
},
}
})
window.ipfs = ipfs
ipfs.on('error', (e) => handleError(e))
ipfs.on('ready', async () => {
openButton.disabled = false
createButton.disabled = false
statusElm.innerHTML = "IPFS Started"
orbitdb = await OrbitDB.createInstance(ipfs)
})
openButton.disabled = false
createButton.disabled = false
statusElm.innerHTML = "IPFS Started"
orbitdb = await OrbitDB.createInstance(ipfs)
const load = async (db, statusText) => {
// Set the status text