You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.
I want to store the port option in a database for dat-node so we can reuse whatever port worked last. But I think we need some way to make listen & join async. Maybe opts.autoListen or something (default: true), would be a way to do this? Or any other more straightforward suggestions?
Sudo code implementation in dat-node:
// Check for existing port saved// PROBLEM: Happens asyncif(opts.port&&db){varsubDb=sub(db,`${encoding.toStr(archive.discoveryKey)}-network`)subDb.get('port',function(err,val){if(err&&!err.notFound)thrownewError(err)if(val)opts.port=valdoListen()})}// Happens syncopts.autoListen=falsevarswarm=hyperdiscovery(archive,opts)// ... later with `autoListen = false`functiondoListen(){swarm.once('error',function(){swarm.listen(0)})swarm.listen(opts.port)swarm.join(this.archive.discoveryKey)swarm.once('listening',function(){subDb.put('port',swarm.port)// save whatever port succeeded})}
We could make the whole network function async in dat-node too. Maybe that is the easier solution but the rest of the networking APIs are sync.
The text was updated successfully, but these errors were encountered:
I want to store the port option in a database for
dat-node
so we can reuse whatever port worked last. But I think we need some way to makelisten
&join
async. Maybeopts.autoListen
or something (default: true), would be a way to do this? Or any other more straightforward suggestions?Sudo code implementation in dat-node:
We could make the whole network function async in dat-node too. Maybe that is the easier solution but the rest of the networking APIs are sync.
The text was updated successfully, but these errors were encountered: