conradoqg/naivecoin

Run many node in this blockchain

votinhthuong opened this issue · 2 comments

As you say, if I want to run two nodes in this blockchain, so I have to run 2 command in 2 separated terminal:
$ node bin/naivecoin.js -p 3001 --name 1
$ node bin/naivecoin.js -p 3002 --name 2 --peers http://localhost:3001

So if I want to run more than 2 node, for example 3 node, so what list of peers in the third terminal?

Is that true:
$ node bin/naivecoin.js -p 3001 --name 1
$ node bin/naivecoin.js -p 3002 --name 2 --peers http://localhost:3001
$ node bin/naivecoin.js -p 3003 --name 3 --peers http://localhost:3001, http://localhost:3002

If I run like that, it return an errors:
warn - thuong3: Unable to get latest block from http://localhost:3002,/blockchain/blocks/latest: connect ECONNREFUSED 127.0.0.1:80
warn - thuong3: Unable to send me to peer http://localhost:3002,/node/peers: connect ECONNREFUSED 127.0.0.1:80
warn - thuong3: Unable to send me to peer http://localhost:3002,/node/peers: connect ECONNREFUSED 127.0.0.1:80
warn - thuong3: Unable to get transations from http://localhost:3002,/blockchain/transactions: connect ECONNREFUSED 127.0.0.1:80
warn - thuong3: Unable to send me to peer http://localhost:3002,/node/peers: connect ECONNREFUSED 127.0.0.1:80
warn - thuong3: Unable to send me to peer http://localhost:3002,/node/peers: connect ECONNREFUSED 127.0.0.1:80

I think the problem is because of how you set the peers, try to do this instead:

node bin/naivecoin.js -p 3003 --name 3 --peers http://localhost:3001 --peers http://localhost:3002

Best

Check the answer #35.