0.28.0 • Published 1 year ago
@node-lightning/graph v0.28.0
@node-lightning/graph
This library constructs a graph as an adjacency list from P2P gossip messages.
This class includes the following types:
- GraphManger - constructs a graph from gossip messages
- Graph - adjacency list representation of a graph
- Node - vertex in the graph
- Channel - directional edge in the graph
- ChannelSettings - one directional edge information
Examples
Message from a gossip emitter (defined in @node-lightning/wire) will be used to construct an adjacency list based graph.
const graphManager = new GossipManager(gossipEmitter);
graphManager.on("node", (node: Node) => {
//
});
graphManager.on("channel", (channel: Channel) => {
//
});
graphManager.on("channel_update", (channel: Channel, settings: ChannelSettings) => {
//
});
The following events are emitted for the corresponding gossip message:
channel_announcement message
- emits node event for node1 in channel
- emits node event for node2 in channel
- emits channel
channel_update message
- emits channel_update event
node_announcement message
- emits node event
LND Serialization
You can serialize the graph instance in the same manner as the serialization used in LND RPC calls.
const serializer = new LndSerializer();
// to a plain-old JavaScript object
serializer.toObject(graph);
// to JSON
serializer.toJson(graph);
0.28.0
1 year ago
0.27.2
2 years ago
0.27.4
2 years ago
0.27.0
2 years ago
0.26.1
3 years ago
0.26.0
3 years ago
0.25.0
3 years ago
0.24.1
3 years ago
0.24.0
3 years ago
0.23.0
3 years ago
0.23.0-alpha.0
3 years ago
0.22.1
3 years ago
0.22.0
3 years ago
0.21.1
3 years ago
0.21.0
3 years ago
0.20.1
4 years ago
0.10.0
4 years ago
0.9.0
4 years ago