4 Commits

Author SHA1 Message Date
Râu Cao
d8dda84fd6 Update bootstrap node 2022-09-30 15:19:01 +02:00
ba7c98b564 1.2.0 2019-08-18 12:40:27 +02:00
3f03368e25 Merge branch 'refactor/bootstrap_node' of kosmos/kredits-ipfs-pinner into master 2019-08-18 09:03:51 +00:00
a3d21ebb30 Refactor bootstrap node connect, add CLI argument
Removes the superfluous wrapper function (as the API already returns a
Promise). Also adds a command line argument so you can choose a
different bootstrap node.
2019-08-14 10:12:07 +02:00
3 changed files with 15 additions and 15 deletions

View File

@@ -5,7 +5,15 @@ const IpfsPinner = require('./lib/ipfs-pinner');
const debug = require('debug')('ipfs-pinner');
const argv = require('yargs')
.default({ network: 'rinkeby', apm: 'open.aragonpm.eth', host: 'localhost', port: '5001', protocol: 'http', monitor: true })
.default({
network: 'rinkeby',
apm: 'open.aragonpm.eth',
host: 'localhost',
port: '5001',
protocol: 'http',
monitor: true,
bootstrapNode: '/dns4/barnard.kosmos.org/tcp/4001/ipfs/QmbqZCZ2RzVr4r1UEdFak6ra76kHxtGmfV9r3e1Ev6Tj5D'
})
.boolean('monitor')
.describe({
network: 'Ethereum network to connect to',
@@ -14,7 +22,8 @@ const argv = require('yargs')
host: 'IPFS API host',
port: 'IPFS API port',
protocol: 'IPFS API protocol',
monitor: 'Monitor contract events for new IPFS documents'
monitor: 'Monitor contract events for new IPFS documents',
bootstrapNode: 'IPFS node address to connect to before fetching documents'
})
.example('$0 --network rinkeby --host localhost', 'Pins all existing IPFS documents to the IPFS API running on localhost and monitors for new events.')
.argv;
@@ -27,15 +36,6 @@ const ipfsConfig = {
console.log(`Using IPFS:`, ipfsConfig);
async function swarmConnect (ipfsApi, address) {
return new Promise((resolve, reject) => {
debug(`Connecting to known IPFS node: ${address}`);
ipfsApi.swarm.connect(address, err => {
return err ? reject(err) : resolve();
})
});
}
(async () => {
try {
const kredits = await Kredits.for(
@@ -49,8 +49,8 @@ async function swarmConnect (ipfsApi, address) {
await ipfsApi.id();
// TODO discover address dynamically from somewhere
await swarmConnect(ipfsApi, '/ip4/46.4.18.160/tcp/4001/ipfs/QmZ4Lpzhz8bafbTYvEMMCmrbrMM4JfyHDR23WbCSAd9bo7');
debug(`Connecting to known IPFS node ${argv.bootstrapNode}`);
await ipfsApi.swarm.connect(argv.bootstrapNode);
const ipfsPinner = new IpfsPinner(kredits);

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@67p/kredits-ipfs-pinner",
"version": "1.1.0",
"version": "1.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@kosmos/kredits-ipfs-pinner",
"version": "1.1.0",
"version": "1.2.0",
"description": "Pins IPFS data of a Kredits organization on an IPFS node",
"main": "index.js",
"scripts": {