Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b11dbb9fde | |||
|
|
bfb51d48bc | ||
| f2f884a317 | |||
| 2a3c021737 | |||
| c4c95d9b38 | |||
| 2d08cc929f | |||
| 5d36ca05a5 |
@@ -9,11 +9,11 @@ config flags, in case it is not running on localhost with default ports.)
|
|||||||
|
|
||||||
### With NPX magic
|
### With NPX magic
|
||||||
|
|
||||||
npx @67p/kredits-ipfs-pinner
|
npx @kosmos/kredits-ipfs-pinner
|
||||||
|
|
||||||
### Global install
|
### Global install
|
||||||
|
|
||||||
npm install -g @67p/kredits-ipfs-pinner
|
npm install -g @kosmos/kredits-ipfs-pinner
|
||||||
kredits-ipfs-pinner
|
kredits-ipfs-pinner
|
||||||
|
|
||||||
### From repo
|
### From repo
|
||||||
|
|||||||
20
index.js
20
index.js
@@ -1,6 +1,8 @@
|
|||||||
const debug = require('debug')('ipfs-pinner');
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const Kredits = require('kredits-contracts');
|
const Kredits = require('kredits-contracts');
|
||||||
const IpfsPinner = require('./lib/ipfs-pinner');
|
const IpfsPinner = require('./lib/ipfs-pinner');
|
||||||
|
const debug = require('debug')('ipfs-pinner');
|
||||||
|
|
||||||
const argv = require('yargs')
|
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 })
|
||||||
@@ -25,6 +27,15 @@ const ipfsConfig = {
|
|||||||
|
|
||||||
console.log(`Using IPFS:`, 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 () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const kredits = await Kredits.for(
|
const kredits = await Kredits.for(
|
||||||
@@ -34,7 +45,12 @@ console.log(`Using IPFS:`, ipfsConfig);
|
|||||||
|
|
||||||
// check the connection to the IPFS client
|
// check the connection to the IPFS client
|
||||||
// TODO redesign IPFS wrapper API and do not use an internal attribute
|
// TODO redesign IPFS wrapper API and do not use an internal attribute
|
||||||
await kredits.ipfs._ipfsAPI.id();
|
const ipfsApi = kredits.ipfs._ipfsAPI;
|
||||||
|
|
||||||
|
await ipfsApi.id();
|
||||||
|
|
||||||
|
// TODO discover address dynamically from somewhere
|
||||||
|
await swarmConnect(ipfsApi, '/ip4/46.4.18.160/tcp/4001/ipfs/QmZ4Lpzhz8bafbTYvEMMCmrbrMM4JfyHDR23WbCSAd9bo7');
|
||||||
|
|
||||||
const ipfsPinner = new IpfsPinner(kredits);
|
const ipfsPinner = new IpfsPinner(kredits);
|
||||||
|
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@67p/kredits-ipfs-pinner",
|
"name": "@67p/kredits-ipfs-pinner",
|
||||||
"version": "1.0.2",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@67p/kredits-ipfs-pinner",
|
"name": "@kosmos/kredits-ipfs-pinner",
|
||||||
"version": "1.0.2",
|
"version": "1.1.0",
|
||||||
"description": "Pins IPFS data of a Kredits organization on an IPFS node",
|
"description": "Pins IPFS data of a Kredits organization on an IPFS node",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user