Pin using names (#49 again) (#51)

This commit is contained in:
Maciej Hirsz
2018-09-24 21:53:16 +02:00
committed by GitHub
parent 5e995ea21d
commit e0012099c0
5 changed files with 13 additions and 12 deletions
+4 -4
View File
@@ -8,7 +8,7 @@ const TIMEOUT_BASE = (1000 * 5) as Types.Milliseconds; // 5 seconds
const TIMEOUT_MAX = (1000 * 60 * 5) as Types.Milliseconds; // 5 minutes
export class Connection {
public static async create(pins: PersistentSet<Types.NodeId>, update: Update): Promise<Connection> {
public static async create(pins: PersistentSet<Types.NodeName>, update: Update): Promise<Connection> {
return new Connection(await Connection.socket(), update, pins);
}
@@ -65,9 +65,9 @@ export class Connection {
private socket: WebSocket;
private state: Readonly<State>;
private readonly update: Update;
private readonly pins: PersistentSet<Types.NodeId>;
private readonly pins: PersistentSet<Types.NodeName>;
constructor(socket: WebSocket, update: Update, pins: PersistentSet<Types.NodeId>) {
constructor(socket: WebSocket, update: Update, pins: PersistentSet<Types.NodeName>) {
this.socket = socket;
this.update = update;
this.pins = pins;
@@ -172,7 +172,7 @@ export class Connection {
case Actions.AddedNode: {
const [id, nodeDetails, nodeStats, blockDetails, location] = message.payload;
const pinned = this.pins.has(id);
const pinned = this.pins.has(nodeDetails[0]);
const node = { pinned, id, nodeDetails, nodeStats, blockDetails, location };
nodes.set(id, node);