P2P sharing with PHP?

Well, for some time I have been studying about blockchain, consequently P2P networks, until I arrived in IPFS and I found it very cool, but I did not find anything in PHP, usually the implementations of P2P networks are made in Golang or Python. I have some doubts about this:

  1. In a p2p network, how does one peer find the other?

  2. Is there any implementation of these P2P protocols in PHP?

  3. I am studying this in order to do a kind of smart contract in PHP, will it be feasible?

Thank you all, if I get good answers maybe this will turn into an academic article.

Author: João Bosco, 2019-07-23

1 answers

PHP is a language that was created with a focus on generating dynamic pages in HTML, and although it has evolved into a general purpose language, it has not incorporated the best option of the tools needed for generic applications - thus, it is possible to create a P2P network and implement existing network protocols in PHP, but because it is not the It would be dangerous to speculate why this here, because I could not be objective. All that is necessary to implement any network protocol is that there is an API for pure sockets, and a way to manipulate bytes and bits - the rest is a question of how practical it is, in the syntax of the language to write concise, clean code with good security practices and easy maintenance.

Already, as for smart contracts, here's another story - blockchains that allow smart contracts do this with a specific bytecode, which runs on chain nodes, and has one or more languages created specifically to create smart-contracts in that chain (the exception I know of IS EOS that uses C++). But, if you take Ethereum for example, which is probably the most popular blockchain for smartcontracts - it has 2 or 3 distinct languages, but its own, for creating smartcontracts - the most popular being a more similar, but without being, Javascript (solidity) and another similar, but without being, Python (Vyper).

As for the first part, of " as a peer find another "- in the configuration of each P2P project there is a list of" initial partners " - it is even a form of centralization - but nothing prevents forks of the code from swapping this initial list of known partners, and in any case, they are only configuration. And, among the calls that are automatically made to the other nodes, there are always calls to search for other partner nodes, and a well-made algorithm will repeat these calls to choose more distant, different nodes, but with a good response time - in this way, information about distant nodes is propagated and the network maintains its decentralized character, even each node "zeroed" starting with a fixed list of partners.

 4
Author: jsbueno, 2019-07-23 02:07:24