Home Reference Source Repository

src/ipfs-keep-alive.js

export const twelveHours = 43200000;
export default (published, ipfs, cb) => {
  if (!ipfs) {
    const IPFS = require('ipfs-api');
    ipfs = new IPFS();
  }
	const aliveTimeout = () => {
    setTimeout(async () => {
      published = await ipfs.name.resolve(published['name']);
      published = await ipfs.name.publish(published['value']);
      if (cb) {
        cb(null, published);
      }
      return aliveTimeout();
		}, twelveHours);
  }
  aliveTimeout();
};