Open manix opened 7 years ago
Websockets are needed. Although you can query the network via http but how will you broadcast to the network when you add a block. Constantly querying the network will be a very bad solution.
There is a web socket functionality in express. This will allow you to share the same project between http and ws. I am not saying to not use web sockets... Thanks
Le sam. 18 nov. 2017 à 23:08, Abhishek Deora notifications@github.com a écrit :
Websockets are needed. Although you can query the network via http but how will you broadcast to the network when you add a block. Constantly querying the network will be a very bad solution.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lhartikk/naivechain/issues/14#issuecomment-345475098, or mute the thread https://github.com/notifications/unsubscribe-auth/AALqXSGKFGuKp4K4QcG7eHmZZ1K1-AkWks5s31VzgaJpZM4PZu1N .
There is clear separation of concerns between the different ports.
The P2P port is for only peer to peer communication with other nodes. This port should be public to internet as other nodes should be able to connect to your node.
The other port (HTTP_PORT) is used only for controlling the node. It should not be public to the internet and only the user of the node should be able to access it.
This same kind of "architetcture" is used in all of the "well-known" blockchain implementations I know of (Bitcoin, Ethereum, Litecoin etc.)
@adeora7 you have /addPeer
which could store peer addresses instead of creating a websocket client and then simply post there, you wouldn't need to do any kind of polling.
You can pass the http server app to the ws server and have it all work under 1 port. Is it purposely made to use 2 ports and why?
On second thought, why are websockets used at all? You can query the network via http, this will make the program even simpler and with less code which as I see is the main concern in this repo?