P2P sharing with PHP?

Asked

Viewed 191 times

2

Well, for some time I have been studying about blockchain, consequently p2p networks, until I arrived in IPFS and I found it very cool all, however, I did not find anything in PHP, generally p2p network implementations are made in Golang or Python. I have some doubts about that:

  1. In a p2p network, as a peer finds the other?

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

  3. I am studying this in order to make a kind of smart Contract in PHP, will be viable?

Thank you all, if I get good answers maybe this becomes an academic article.

1 answer

4


PHP is a language that has been created with a focus on generating dynamic HTML pages, and although it has evolved into a general-purpose language, it has not incorporated the best choice of 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 best tool for this, it was not done. It would be dangerous to speculate why this is happening here, because I couldn’t be objective. All that is needed to implement any network protocol is that there is an API for pure sockets, and a way of manipulating bytes and bits - the rest is a matter of how practical it is, in language syntax to write code concise, clean, with good practices of security and easy maintenance.

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

As for the first part, from "how one peer finds another" - in the configuration of each P2P project there is a list of "initial partners" - it’s even a form of centralization - but nothing prevents code fonts from changing that initial list of known partners, and anyway, They’re just a setup. And, among the calls that are made automatically to the other nodes, there are always calls to search other nodes partners, and an algorithm well done is repeating these calls to choose nodes more distant, different, but with a good response time - this way, information about distant nodes is propagating and the network maintains its decentralized character, even each node "zeroed" starting with a fixed list of partners.

  • 1

    Now - if you’ll allow me to draw a little fire out of the answer text: learn Python. It’s worth it if you’re after that sort of thing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.