Naming: remove remnants

This commit is contained in:
Mitra Ardron 2019-09-08 15:06:21 +10:00
parent 3605e0a0f5
commit 4addbc3120
4 changed files with 9 additions and 8 deletions

4
API.md
View File

@ -11,7 +11,8 @@ See [Dweb document index](./DOCUMENTINDEX.md) for a list of the repos that make
See [Writing Shims](./WRITINGSHIMS.md) for guidelines for adding a new Transport and adding shims to the Archive
## General API notes and conventions
We use a naming convention that anything starting “p_” returns a promise so you know to "await" it if you want a result.
We were using a naming convention that anything starting “p_” returns a promise so you know to "await" it if you want a result,
this is being phased out as many functions now take a callback or promise.
Ideally functions should take a String, Buffer or where applicable Object as parameters with automatic conversion.
And anything that takes a URL should take either a string or parsed URL object.
@ -604,7 +605,6 @@ See p_resolveNames(urls) and resolveNamesWith(cb)
In practice this means that an application should do.
```
require('@internetarchive/dweb-transports)
require('@internetarchive/dweb-objects/Domain) # Sets the callbacks.
```
When setup this way, then calls to most functions that take an array of urls will first try and expand names.

View File

@ -83,7 +83,8 @@ Error feedback is a little fuzzy.
There are issues with IPFS swarms that we havent been able to figure out about how to ensure that “put”ting to IPFS creates an object that can be read at all other browsers, and persists. See DT issue#2
Naming hasnt been implemented in IPFS yet, partly because IPNS is not available in the JS-IPFS, and partly because IPNS has serious problems:
(requirement to rebroadcast every 24 house so not persistent; merkle tree so change at leaf changes top level; doesnt work in JS-IPFS;) We implemented naming outside of IPFS (in Domain.js) to get it to work.
(requirement to rebroadcast every 24 house so not persistent; merkle tree so change at leaf changes top level; doesnt work in JS-IPFS;)
We implemented naming outside of IPFS (in Naming.js) to get it to work.
#### Implementation on WebTorrent
WebTorrent implements the BitTorrent protocol in the browser. It will work for retrieval of objects and currently has the fastest/most-reliable stream interface.

View File

@ -117,10 +117,9 @@ class Transports {
}
static async p_resolveNames(urls) {
/* If and only if TransportNAME was loaded (it might not be as it depends on higher level classes like Domain and SmartDict)
then resolve urls that might be names, returning a modified array.
/* Resolve urls that might be names, returning a modified array.
*/
if (this.mirror) {
if (this.mirror) { // Dont do using dweb-mirror as our gateway, as always want to send URLs there.
return Array.isArray(urls) ? this.gatewayUrls(urls) : this.gatewayUrl(url);
} else if (this.namingcb) {
return await this.namingcb(urls); // Array of resolved urls
@ -787,6 +786,7 @@ class Transports {
static canonicalName(url, options={}) {
/*
Utility function to convert a variety of missentered, or presumed names into a canonical result that can be resolved or passed to a transport
returns [ protocol e.g. arc or ipfs, locally relevant address e.g. archive.org/metadata/foo or Q12345
*/
if (typeof url !== "string") url = Url.parse(url).href;
// In patterns below http or https; and :/ or :// are treated the same

View File

@ -138,9 +138,9 @@ and `[gun_https_archive.js](https://github.com/internetarchive/dweb-transport/bl
This will also work if the address of the table is a hash for example `xyz:/xyz/Q1234567/commute`
where `Q1234567` would be `xyz`'s address for the metadata table.
The mapping to that table's address can be hard-coded in code, or included in the Domain.js resolution.
The mapping to that table's address can be hard-coded in code, or included in the dweb-transports/Naming.js resolution.
The dweb-archive code needs to know to try Gun for the metadata, and this is configured in [dweb-objects/Domain.js/p_setupOnce()](https://github.com/internetarchive/dweb-objects/blob/master/Domain.js#L404) which we have to run.
The dweb-archive code needs to know to try Gun for the metadata, and this is configured in [./Naming.js]
Note that this configuration mechanism is likely to change in the future though the address (on GUN) checked should remain the same.
File retrieval can work similarly if the platform allows addressing by name.