Skip to content

Commit

Permalink
Adding client to the list of clients and miners when registering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Austin committed Jul 20, 2023
1 parent 0ab6c32 commit 55dd979
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ module.exports = class Blockchain {

this.clientAddressMap.set(client.address, client);
if (client.name) this.clientNameMap.set(client.name, client);

this.clients.push(client);
this.net.register(client);

Expand Down Expand Up @@ -340,6 +341,12 @@ module.exports = class Blockchain {
clients.forEach((client) => {
this.clientAddressMap.set(client.address, client);
if (client.name) this.clientNameMap.set(client.name, client);

// Add client to the list of clients and (if a miner) the list of miners.
this.clients.push(client);
if (client instanceof this.minerClass) this.miners.push(client);

// Set the "network" connection for the client.
client.net = this.net;
this.net.register(client);
});
Expand Down

0 comments on commit 55dd979

Please sign in to comment.