mirror of https://codeberg.org/pzp/zooboard.git
move hacky scheduler to new ppppp-net
This commit is contained in:
parent
14000ecae1
commit
8003d9ba31
22
main.js
22
main.js
|
@ -3,7 +3,6 @@ const Path = require('node:path')
|
||||||
const URL = require('node:url')
|
const URL = require('node:url')
|
||||||
const p = require('node:util').promisify
|
const p = require('node:util').promisify
|
||||||
const Keypair = require('ppppp-keypair')
|
const Keypair = require('ppppp-keypair')
|
||||||
const awaitable = require('pull-awaitable')
|
|
||||||
|
|
||||||
// WARNING monkey patch! --------------------------------------
|
// WARNING monkey patch! --------------------------------------
|
||||||
const na = require('sodium-native')
|
const na = require('sodium-native')
|
||||||
|
@ -107,12 +106,6 @@ async function loadAccount() {
|
||||||
await p(peer.set.load)(id)
|
await p(peer.set.load)(id)
|
||||||
await p(peer.dict.load)(id)
|
await p(peer.dict.load)(id)
|
||||||
|
|
||||||
// Read hubs FIXME: this should be in the ppppp-net scheduler
|
|
||||||
const multiaddrs = peer.set.values('hubs')
|
|
||||||
for (const multiaddr of multiaddrs) {
|
|
||||||
scheduleWithHub(multiaddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read profile
|
// Read profile
|
||||||
const profile = peer.dict.read(id, 'profile')
|
const profile = peer.dict.read(id, 'profile')
|
||||||
const name = profile?.name ?? ''
|
const name = profile?.name ?? ''
|
||||||
|
@ -217,20 +210,6 @@ function subscribeToReadElements() {
|
||||||
}, 32)
|
}, 32)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function scheduleWithHub(multiaddr) {
|
|
||||||
const hubRPC = await p(peer.net.connect)(multiaddr)
|
|
||||||
|
|
||||||
// FIXME: this should be in the ppppp-net scheduler
|
|
||||||
for await (const attendants of awaitable(hubRPC.hub.attendants())) {
|
|
||||||
for (const attendant of attendants) {
|
|
||||||
if (attendant !== peer.shse.pubkey) {
|
|
||||||
const tunnelMultiaddr = `/tunnel/${hubRPC.shse.pubkey}.${attendant}/shse/${attendant}`
|
|
||||||
peer.net.connect(tunnelMultiaddr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handlePPPPPUri(ev, uri) {
|
async function handlePPPPPUri(ev, uri) {
|
||||||
if (!globalAccountID) {
|
if (!globalAccountID) {
|
||||||
setTimeout(handlePPPPPUri, 100, null, uri)
|
setTimeout(handlePPPPPUri, 100, null, uri)
|
||||||
|
@ -244,7 +223,6 @@ async function handlePPPPPUri(ev, uri) {
|
||||||
case 'join': {
|
case 'join': {
|
||||||
try {
|
try {
|
||||||
await p(peer.hubClient.addHub)(command.multiaddr)
|
await p(peer.hubClient.addHub)(command.multiaddr)
|
||||||
scheduleWithHub(command.multiaddr)
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to properly join hub', err)
|
console.error('Failed to properly join hub', err)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,9 +28,8 @@
|
||||||
"ppppp-conductor": "github:staltz/ppppp-conductor#51d61bcd5b49192b22027d0e31a3cbf3c691724c",
|
"ppppp-conductor": "github:staltz/ppppp-conductor#51d61bcd5b49192b22027d0e31a3cbf3c691724c",
|
||||||
"ppppp-hub-client": "github:staltz/ppppp-hub-client#554a36e46637c5e6314d3393db20736f2b8e59bc",
|
"ppppp-hub-client": "github:staltz/ppppp-hub-client#554a36e46637c5e6314d3393db20736f2b8e59bc",
|
||||||
"ppppp-invite": "github:staltz/ppppp-invite#745eea3de0b98a4896face25cb31288c9b0c9ed2",
|
"ppppp-invite": "github:staltz/ppppp-invite#745eea3de0b98a4896face25cb31288c9b0c9ed2",
|
||||||
"ppppp-net": "github:staltz/ppppp-net#f5545fd7d9cedd323d2d3614c1532dd7969f492d",
|
"ppppp-net": "github:staltz/ppppp-net#809d3e774bca8742652be06e7e39b01182dca193",
|
||||||
"ppppp-promise": "github:staltz/ppppp-promise#55a48ddd069e8b9673442927a9f91d6931cb520d",
|
"ppppp-promise": "github:staltz/ppppp-promise#55a48ddd069e8b9673442927a9f91d6931cb520d",
|
||||||
"pull-awaitable": "1.0.0",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-outside-click-handler": "1.3.0",
|
"react-outside-click-handler": "1.3.0",
|
||||||
|
|
Loading…
Reference in New Issue