Skip to content

Instantly share code, notes, and snippets.

@GpanosXP
Last active September 24, 2017 09:05
Show Gist options
  • Save GpanosXP/5099e84925518d83f3767b4e61669771 to your computer and use it in GitHub Desktop.
Save GpanosXP/5099e84925518d83f3767b4e61669771 to your computer and use it in GitHub Desktop.
Finds the % of non-zero value tips (unconfirmed transactions) on an IOTA full node.
var iota = new IOTA();
var th, t, total, counter;
iota.api.getTips((error, tipHashes) => {
th = tipHashes;
console.log("Counting useful (non-zero) tips, please wait...");
iota.api.getTransactionsObjects(tipHashes, (error, tips) => {
t = tips;
total = tips.length;
counter = 0;
for (var i = 0; i < total; i++) if (tips[i].value) counter++;
console.log("Total tips: " + total);
console.log("Useful tips: " + counter);
console.log("Useful tips percentage: " + (100 * counter / total).toFixed(3));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment