Create a gist now

Instantly share code, notes, and snippets.

@bretton /README.md forked from tyzbit/README.md
Last active Mar 20, 2018

What would you like to do?
The Lightning Network (Testnet)

Forked from vasturiano, with dataset and minor other changes.

Forked from tyzbit, with new dataset from four hosts, initial jq combine command added

Latest

The Lightning Network as seen from my three nodes, with tyzbit node, at about 22:00 UTC on Feb 20 2018. This data is updated manually when I feel like it.

view

Output of 4 * (lncli describegraph) combined with:

jq -s add describegraph*.json > pregraph.json

Then format combined graph for usage in this tool as follows:

cat pregraph.json | jq -c '{ "nodes": .nodes | map({ "id": .pub_key, "alias": .alias|match("[^\u0000]+")| .string, "group": 1, "color": .color, "addresses": .addresses }), "links": .edges | map({"source": .node1_pub, "target": .node2_pub, "capacity": .capacity|tonumber }) }' > graph.json

Notes:

  • Nodes are colored according to settings set by the node operators.
  • Lines are channels between nodes.
  • Nodes that fly off into the background do not have any visible channels.
  • Line colors are representative of the channel capacity, but is colored dynamically.
  • Click on a node to see its address information.
function getGraphDataSets() {
const loadBlocks = function(Graph) {
qwest.get('graph.json').then((_, data) => {
//data.nodes.forEach(node => { node.name = `${node.alias?node.alias+': ':''}${node.pub_key || node.id}` });
data.nodes.forEach(node => {
node.name = `${node.alias}`
var capacity = 0;
var links = 0;
// check each link, and if it connects to the node, up the node's capacity.
node.size = data.links.forEach(link => {
if ( (node.id == link.source) || (node.id == link.target) ) {
links = links + 1;
capacity = capacity + link.capacity;
}
});
// capacity is in BTC
node.capacity = capacity/100000000;
node.averagechansize = (node.capacity/links);
node.links = links;
// size indicative of average channel size
node.size = node.capacity*10
});
Graph
.cooldownTicks(300)
.cooldownTime(20000)
.nodeColor('color')
.nodeVal('size')
.nodeResolution(4)
.onNodeClick(function(node) {
document.getElementById('graph-data-description').innerHTML = `Total value of this node's channels: ${node.capacity} BTC. Average channel size: ${node.averagechansize} BTC. Total number of channels: ${node.links}.`
node.addresses.forEach(function(address) {
document.getElementById('graph-data-description').innerHTML += "<font color=\"green\" size=\"4em\"><br><b>" + node.alias + "</b>: " + node.id + "@" + address.addr + "</font>"
})
if ( node.addresses.length < 1 ) {
document.getElementById('graph-data-description').innerHTML += "<font color=\"red\" size=\"4em\"><br><b>" + node.alias + "</b> (" + node.id + ") is not advertising any addresses</font>"
}
})
.linkAutoColorBy('capacity')
.linkLabel('capacity')
.linkOpacity(0.4)
.forceEngine('ngraph')
.graphData(data);
});
};
loadBlocks.description = "<em>Lightning TESTNET</em> data (<a href='https://gist.github.com/bretton/4a51ab6aeba8e7a836840aed727566ad'>https://gist.github.com/bretton/4a51ab6aeba8e7a836840aed727566ad</a>)";
return [loadBlocks];
}
This file has been truncated, but you can view the full file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment