Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 1x 45x 45x 4x 4x 31x 31x 9x 9x | import { BitField } from "@node-lightning/core";
import { Address } from "@node-lightning/wire";
import { Channel } from "./channel";
/**
* Reperesents a node in the p2p network.
*/
export class Node {
public nodeId: Buffer;
public lastUpdate: number;
public alias: Buffer;
public addresses: Address[] = [];
public rgbColor: Buffer;
public features: BitField;
/**
* Channels that the node belongs to
*/
public channels: Map<bigint, Channel> = new Map();
/**
* Gets the alias as human readable string
*/
get aliasString(): string {
return this.alias ? this.alias.toString("utf8").replace(/\0/g, "") : "";
}
/**
* Gets the color as a an RGB color string
*/
get rgbColorString(): string {
return this.rgbColor ? "#" + this.rgbColor.toString("hex") : "#000000";
}
/**
* Adds a channel to the node's channel list
*/
public linkChannel(channel: Channel) {
const key = channel.shortChannelId.toNumber();
this.channels.set(key, channel);
}
/**
* Remove a channel from the node's channel list
*/
public unlinkChannel(channel: Channel) {
const key = channel.shortChannelId.toNumber();
this.channels.delete(key);
}
}
|