Open chrisekelley opened 6 years ago
To map the hashbase url to the dat uuid, datGateway, which extends DatLibrarian, has a promising method:
resolve
Promification of dat-link-resolve for convenience's sake.
Parameters
link (String | Buffer) Link to a Dat archive
Examples
DatLibrarian.resolve('garbados.hashbase.io').then((key) => {
console.log(key)
> 'c33bc8d7c32a6e905905efdbf21efea9ff23b00d1c3ee9aea80092eaba6c4957'
})
Returns Promise<Buffer> Key of that Dat archive
See bunsen/www/nodejs_project/index.js for example of using DatGateway:
const gateway = new DatGateway({ dir, dat, max, period, ttl })
gateway
.load()
.then(() => {
return gateway.listen(port)
})
.then(function () {
console.log('[dat-gateway] Now listening on port ' + port)
})
.catch(console.error)
// gateway.on('join', (dat) => {
// // let dar = dat.archive.
// let connections = dat.network.connections.length
// let key = dat.options.key
// console.log(key + " has " + connections + " peers.")
// })
So, this may be as simple as
gateway.resolve('garbados.hashbase.io').then((key) => {
console.log(key)
> 'c33bc8d7c32a6e905905efdbf21efea9ff23b00d1c3ee9aea80092eaba6c4957'
})
We'd then need to provide it as a service by the node server.
Then we need to make this available to the bunsen-ui polymer custom element code. So, in bunsen-ui/src/bunsen-app/bunsen-app.js, we'd fetch this array of hashbase urls:dat uuids from the server, and then fetch them when writing the datSites localStorage object
{"address": "${address}", "url": "${url}"}
Here's where we are with the peers UI:
Peer connections are currently displayed at the bottom of the screen, with a substring of the dat's uuid. this data does not need to always be displayed. Why not enhance the history page to display it, and offer more options?
Current history screen:
Proposed update: beside each link there would be a button that displays current number of peers. Clicking this button would reveal peer sharing details. The button marked C would clone the dat.