UNPKG

@node-lightning/graph

Version:
42 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Channel = void 0; class Channel { /** * Gets the most recently updated timestamp based on the settings * from the two nodes */ get lastUpdate() { const t1 = (this.node1Settings && this.node1Settings.timestamp) || 0; const t2 = (this.node2Settings && this.node2Settings.timestamp) || 0; return Math.max(t1, t2); } /** * Routable when nodes are known and validated and at least one * node has broadcast its relay fees */ get isRoutable() { return !!this.nodeId1 && !!this.nodeId2 && !!(this.node1Settings || this.node2Settings); } /** * Update channel settings */ updateSettings(settings) { if (settings.direction === 0) { if (this.node1Settings && this.node1Settings.timestamp > settings.timestamp) { return false; } this.node1Settings = settings; return true; } else { if (this.node2Settings && this.node2Settings.timestamp > settings.timestamp) { return false; } this.node2Settings = settings; return true; } } } exports.Channel = Channel; //# sourceMappingURL=channel.js.map