From ba5f67861f34a8ef61a02dcce83960cfdcc04442 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 23 Oct 2020 12:08:36 +0200 Subject: [PATCH 1/3] Change IPFS bootstrap node --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9b8e479..0e33156 100755 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ const argv = require('yargs') port: '5001', protocol: 'http', monitor: true, - bootstrapNode: '/ip4/46.4.18.160/tcp/4001/ipfs/QmZ4Lpzhz8bafbTYvEMMCmrbrMM4JfyHDR23WbCSAd9bo7' + bootstrapNode: '/ip4/104.248.95.16/tcp/4001/ipfs/QmbqZCZ2RzVr4r1UEdFak6ra76kHxtGmfV9r3e1Ev6Tj5D' // barnard.kosmos.org }) .boolean('monitor') .describe({ -- 2.25.1 From 9c34e4c9130225a9e1dd55c2464472361aaa4f91 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 25 Oct 2020 10:59:59 +0100 Subject: [PATCH 2/3] WIP Use new IPFS peering config Currently crashes go-ipfs 0.6 for some reason. --- index.js | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 0e33156..bf4cef7 100755 --- a/index.js +++ b/index.js @@ -3,6 +3,14 @@ const Kredits = require('kredits-contracts'); const IpfsPinner = require('./lib/ipfs-pinner'); const debug = require('debug')('ipfs-pinner'); +const { inspect } = require('util'); + +// TODO make configurable +// barnard.kosmos.org +const peerId = "QmbqZCZ2RzVr4r1UEdFak6ra76kHxtGmfV9r3e1Ev6Tj5D"; +const peerAddrs = [ "/ip4/104.248.95.16/tcp/4001" ]; +const bootstrapNode = `${peerAddrs[0]}/ipfs/${peerId}`; +const peerConfig = { "ID": peerId, "Addrs": [ peerAddrs ] }; const argv = require('yargs') .default({ @@ -12,7 +20,7 @@ const argv = require('yargs') port: '5001', protocol: 'http', monitor: true, - bootstrapNode: '/ip4/104.248.95.16/tcp/4001/ipfs/QmbqZCZ2RzVr4r1UEdFak6ra76kHxtGmfV9r3e1Ev6Tj5D' // barnard.kosmos.org + bootstrapNode: bootstrapNode }) .boolean('monitor') .describe({ @@ -49,18 +57,33 @@ console.log(`Using IPFS:`, ipfsConfig); await ipfsApi.id(); - debug(`Connecting to known IPFS node ${argv.bootstrapNode}`); - await ipfsApi.swarm.connect(argv.bootstrapNode); + // debug(`Connecting to known IPFS node ${argv.bootstrapNode}`); + // await ipfsApi.swarm.connect(argv.bootstrapNode); - const ipfsPinner = new IpfsPinner(kredits); + let peers; - ipfsPinner.pinAll().then(pins => { - console.log(`Pinned ${pins.length} existing documents`); - }); + try { + peers = await ipfsApi.config.get('Peering.Peers'); + } catch(e) { /* No peers configured */ } - ipfsPinner.monitor(pin => { - console.log('Pinned a new document:', pin[0]["hash"]); - }); + if (peers) { + // TODO check for kosmos peer + debug('IPFS peers configured:'); + debug(inspect(peers.map(p => p.ID))); + } else { + debug(`Configuring persistent IPFS peer: ${peerId}`); + await ipfsApi.config.set('Peering', { "Peers": [ peerConfig ]}); + } + + // const ipfsPinner = new IpfsPinner(kredits); + + // ipfsPinner.pinAll().then(pins => { + // console.log(`Pinned ${pins.length} existing documents`); + // }); + // + // ipfsPinner.monitor(pin => { + // console.log('Pinned a new document:', pin[0]["hash"]); + // }); console.log(`Subscribed to DAO: ${kredits.Kernel.contract.address}`); } catch(e) { -- 2.25.1 From ef1ae5add7e49d26823a5e2aa156648b2ea58f08 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Mon, 26 Oct 2020 09:16:00 +0100 Subject: [PATCH 3/3] Use DNS multiaddr Makes it much easier to identify the node you're connecting to --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index bf4cef7..cbe99e2 100755 --- a/index.js +++ b/index.js @@ -6,9 +6,8 @@ const debug = require('debug')('ipfs-pinner'); const { inspect } = require('util'); // TODO make configurable -// barnard.kosmos.org const peerId = "QmbqZCZ2RzVr4r1UEdFak6ra76kHxtGmfV9r3e1Ev6Tj5D"; -const peerAddrs = [ "/ip4/104.248.95.16/tcp/4001" ]; +const peerAddrs = [ "/dns4/barnard.kosmos.org/tcp/4001" ]; const bootstrapNode = `${peerAddrs[0]}/ipfs/${peerId}`; const peerConfig = { "ID": peerId, "Addrs": [ peerAddrs ] }; -- 2.25.1