-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
75 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var ipfsAPI = require('ipfs-api') | ||
|
||
module.exports = { | ||
apiCtl: ipfsAPI('/ip4/127.0.0.1/tcp/5001') | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
exports.mirror = require('./mirror') | ||
exports.clone = require('./clone') | ||
exports.registryCache = require('./registry-cache') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const debug = require('debug') | ||
const log = debug('registry-mirror') | ||
const async = require('async') | ||
log.error = debug('registry-mirror:error') | ||
const config = require('./config') | ||
|
||
exports = module.exports | ||
|
||
exports.connect = (callback) => { | ||
// TODO support connection to more than one node | ||
// TODO check which nodes are missing from the list first | ||
const updaterNodes = { | ||
biham: '/ip4/188.40.114.11/tcp/4001/ipfs/QmZY7MtK8ZbG1suwrxc7xEYZ2hQLf1dAWPRHhjxC8rjq8E' | ||
} | ||
|
||
config.apiCtl.swarm.connect(updaterNodes.biham, callback) | ||
} | ||
|
||
exports.cacheRegistry = (callback) => { | ||
var registry = '/ipns/QmZY7MtK8ZbG1suwrxc7xEYZ2hQLf1dAWPRHhjxC8rjq8E' | ||
|
||
async.waterfall([ | ||
(cb) => { | ||
config.apiCtl.name.resolve(registry, (err, res) => { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dignifiedquire
Member
|
||
cb(err, res.Path) | ||
}) | ||
}, | ||
config.apiCtl.cat, | ||
(stream, cb) => { | ||
config.apiCtl.block.put(stream, (err, res) => { | ||
cb(err, '/ipfs/' + res.Key) | ||
}) | ||
}, | ||
(ipfsHash, cb) => { | ||
config.apiCtl.files.mv(['/npm-registry', '/npm-registry.bak-' + Date.now().toString()], (err) => { | ||
cb(err, ipfsHash) | ||
}) | ||
}, | ||
(ipfsHash, cb) => { | ||
config.apiCtl.files.cp([ipfsHash, '/npm-registry'], (err) => { | ||
cb(err, ipfsHash) | ||
}) | ||
} | ||
], (err, ipfsHash) => { | ||
callback(err, ipfsHash) | ||
}) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
config.apiCtl
seems like a really hard thing to type and read, why not just call itconfig.api
?