Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Rodney Witcher II 2019-03-21 00:27:12 -07:00
commit aad89bc4ab
2 changed files with 15 additions and 15 deletions

View File

@ -25,13 +25,12 @@ class TransportWOLK extends Transport {
this.name = "WOLK"; // For console log etc this.name = "WOLK"; // For console log etc
//TODO: Change name to WOLK once we understand everything //TODO: Change name to WOLK once we understand everything
this.supportURLs = ['wolk']; this.supportURLs = ['wolk'];
this.supportFunctions = [ 'fetch', 'store', 'connection', 'get', 'set', 'createReadStream' ]; this.supportFunctions = [ 'fetch', 'connection', 'get', 'set', ]; // 'store' - requires chunkdata; 'createReadStream' not implemented
this.status = Transport.STATUS_LOADED; this.status = Transport.STATUS_LOADED;
} }
connection(url) { connection(url) {
console.log("WOLK connection call") debug("connection call")
var wolknode = new WOLK(); var wolknode = new WOLK();
//TODO: cloudstore connection needed //TODO: cloudstore connection needed
return wolknode return wolknode
@ -52,10 +51,10 @@ class TransportWOLK extends Transport {
//make the connection //make the connection
async p_setup1(cb) { async p_setup1(cb) {
await this.wolk.init() await this.wolk.init()
.then( async () => { .then( async () => { //TODO-WOLK check - I'm just not familiar with this construct - an async function inside a .then
if( this.wolk.ecdsaKey == undefined || this.wolk.ecdsaKey == null ) { if( this.wolk.ecdsaKey == undefined || this.wolk.ecdsaKey == null ) {
var wolkName = "user" + Math.floor((Math.random() * 1000) + 1); var wolkName = "user" + Math.floor((Math.random() * 1000) + 1);
console.log("WOLK: createAccount because ecsaKey null") debug("WOLK: createAccount because ecdsaKey null")
return await this.wolk.createAccount(wolkName) return await this.wolk.createAccount(wolkName)
.then( hash => { .then( hash => {
debug("[WOLK] Account Created: [" + wolkName + "] hash: " + hash + " KEY: " + this.wolk.ecdsaKey) debug("[WOLK] Account Created: [" + wolkName + "] hash: " + hash + " KEY: " + this.wolk.ecdsaKey)
@ -82,15 +81,15 @@ class TransportWOLK extends Transport {
return this.wolk.getLatestBlockNumber() return this.wolk.getLatestBlockNumber()
.then( (bn) => { .then( (bn) => {
if (bn >= 0) { if (bn >= 0) {
console.log("[WOLK] STATUS: connected? [1] = BN: " + bn) debug("STATUS: connected? [1] = BN: %s", bn)
this.status = Transport.STATUS_CONNECTED; this.status = Transport.STATUS_CONNECTED;
} else { } else {
console.log("[WOLK] STATUS: connected? [0] = BN: " + bn) debug("STATUS: connected? [0] = BN: %s", bn)
this.status = Transport.STATUS_FAILED; this.status = Transport.STATUS_FAILED;
} }
return this.status; return this.status;
}) })
.catch( (err) => { console.log("Error getting bn: " + err); }) .catch( (err) => { console.error("Error getting bn: " + err); })
} }
// ===== DATA ====== // ===== DATA ======
@ -143,11 +142,11 @@ class TransportWOLK extends Transport {
var responseData = "" var responseData = ""
if( wolkurl.urltype == "key" ) { if( wolkurl.urltype == "key" ) {
console.log("[WOLK] Checking Wolk NoSQL for: " + url) debug("Checking Wolk NoSQL for: %s", url)
return this.wolk.getKey(wolkurl.owner, wolkurl.bucket, wolkurl.path, "latest") return this.wolk.getKey(wolkurl.owner, wolkurl.bucket, wolkurl.path, "latest")
.then(function(responseData) { .then(function(responseData) {
//TODO: error checking //TODO-WOLK: error checking
console.log("WOLK Response: " + JSON.stringify(responseData)); //debug("Response: %s", JSON.stringify(responseData)); //Commented as could be big
return responseData; return responseData;
}) })
.catch( (err) => { .catch( (err) => {
@ -209,7 +208,7 @@ class TransportWOLK extends Transport {
async p_get(url, keys) { async p_get(url, keys) {
var wolkurl = this.parseWolkUrl(url) var wolkurl = this.parseWolkUrl(url)
console.log("WOLK: getting url: " + JSON.stringify(wolkurl)); debug("Getting url: %s", JSON.stringify(wolkurl));
/* /*
console.log("WOLK owner: " + wolkurl.owner); console.log("WOLK owner: " + wolkurl.owner);
console.log("WOLK bucket: " + wolkurl.bucket); console.log("WOLK bucket: " + wolkurl.bucket);

View File

@ -79,17 +79,17 @@ class Transports {
// SEE-OTHER-ADDTRANSPORT // SEE-OTHER-ADDTRANSPORT
static http() { static http() {
// Find an http transport if it exists, so for example YJS can use it. // Find an http transport if it exists.
return Transports._connected().find((t) => t.name === "HTTP") return Transports._connected().find((t) => t.name === "HTTP")
} }
static wolk() { static wolk() {
// Find a Wolk transport if it exists, so for example YJS can use it. // Find a Wolk transport if it exists.
return Transports._connected().find((t) => t.name === "WOLK") return Transports._connected().find((t) => t.name === "WOLK")
} }
static ipfs() { static ipfs() {
// Find an ipfs transport if it exists, so for example YJS can use it. // Find an ipfs transport if it exists, in particular, so YJS can use it.
return Transports._connected().find((t) => t.name === "IPFS") return Transports._connected().find((t) => t.name === "IPFS")
} }
@ -717,6 +717,7 @@ class Transports {
if (typeof url !== "string") url = Url.parse(url).href; if (typeof url !== "string") url = Url.parse(url).href;
// In patterns below http or https; and :/ or :// are treated the same // In patterns below http or https; and :/ or :// are treated the same
const gateways = ["dweb.me", "ipfs.io"]; // Known gateways, may dynamically load this at some point const gateways = ["dweb.me", "ipfs.io"]; // Known gateways, may dynamically load this at some point
// SEE-OTHER-ADDTRANSPORT
const protocols = ["ipfs","gun","magnet","yjs","wolk","arc", "contenthash", "http", "https"]; const protocols = ["ipfs","gun","magnet","yjs","wolk","arc", "contenthash", "http", "https"];
const protocolsWantingDomains = ["arc", "http", "https"]; const protocolsWantingDomains = ["arc", "http", "https"];
const gatewaypatts = [ // Must be before patts because gateway names often start with a valid proto const gatewaypatts = [ // Must be before patts because gateway names often start with a valid proto