-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhenode.js
34 lines (31 loc) · 1.01 KB
/
henode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* HENode
* persistent process that runs an IPFS cacher for all HEN tokens
* bootstraps the whole network and then monitors new mints every 60 seconds
*
* additionally grabs updated blocklists to unpin/kill blocked items
*/
require("console-stamp")(console, {
format: ":date(yyyy-mm-dd HH:MM:ss.l)",
});
const { pinned, save } = require("./lib/state");
const getObjkts = require("./lib/get.objkts.all");
const pinObjkts = require("./lib/pin.objkts");
const pinNewObjkts = async () => {
// call hicdex to get full list of objects
const objkts = await getObjkts();
const newObjkts = objkts.filter((o) => !pinned.includes(o.id));
console.log(`✅ ${newObjkts.length.toLocaleString()} objkts to pin`);
if (newObjkts.length) {
await pinObjkts(newObjkts, (id) => {
pinned.push(id);
save();
});
}
// wait 1 minute before checking hicdex again
setTimeout(pinNewObjkts, 60000);
};
(async () => {
console.log(`running HENode with ${pinned.length} already synced`);
await pinNewObjkts();
})();