Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: What's the difference between a peer and a miner? #12

Open
rampatra opened this issue Mar 9, 2019 · 1 comment
Open

Question: What's the difference between a peer and a miner? #12

rampatra opened this issue Mar 9, 2019 · 1 comment

Comments

@rampatra
Copy link

rampatra commented Mar 9, 2019

I am a bit confused between peers and miners. I know that peers are the ones which have the entire blockchain with them and whenever a new block comes, it is broadcast to all peers, and the peers check the validity and finally add it to the blockchain.

Now I am confused as to who introduces the new block? I see the code which adds a new block which then gets broadcast to all peers but what I do not understand is, who calls the mineCommand()?

function mineCommand(vorpal) {
  vorpal
    .command('mine <data>', 'Mine a new block. Eg: mine hello!')
    .alias('m')
    .action(function(args, callback) {
      if (args.data) {
        blockchain.mine(args.data);
        p2p.broadcastLatest(); 
      }
      callback();
    })
}

From the UI, I get an impression that a peer is the one adding a new block but from the code it doesn't seem so.

@gauravsquadx
Copy link

Each peer has only one miner. Miners from all the nodes in a blockchain compete with each other for validating a block (Proof of work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants