<p>Bitcoin Core’s connection management is probably much more complicated than what you are looking to do. You may want to look into the actual message flow that nodes adhere to for the peer-to-peer protocol and create a very simple implementation of that. You can for example have a look at the Bitcoin Developer Guide’s <a href="https://developer.bitcoin.org/devguide/p2p_network.html" rel="nofollow noreferrer">P2P Network section</a>. There are also several libraries that implement parts of the peer-to-peer protocol in TypeScript and JavaScript which may be more accessible for you to read. You could for example have a look at the <a href="https://github.com/bcoin-org/bcoin" rel="nofollow noreferrer"><code>bcoin</code></a> repository to see if that is more accessible.</p>

CC BY-SA 4.0
2024-09-03T17:44:09.050Z
2024-09-04T12:05:21.877Z
2024-09-04T12:05:21.877Z
Murch
<p>I started to work on my version of blockchain, and for that, I read how everything works, and everything made sense. But when I got to Nodes/CConnman/CNode, after reading for a week, I understood most of the connection between these classes. However, then I saw more classes, and then more classes—I got lost in the sauce. To understand it, I had to learn C++ first. I'm used to writing in TypeScript, so I learned it and implemented the socket in CConnman. After setting up a basic relation where a CNode is created for every incoming connection, I have an array of CNode to keep track of the nodes I'm connected to. But after that, I got lost again. Any suggestions would be appreciated.</p>

<bitcoin-core-development><nodes><p2p><javascript><connection>
How can you make the most basic version of BTC Nodes/Peer to Peer communication?
Rahul Mishra
# How can you make the most basic version of BTC Nodes/Peer to Peer communication?

(Asked by: username_0 on 2024-09-03)

I started to work on my version of blockchain, and for that, I read how everything works, and everything made sense. But when I got to Nodes/CConnman/CNode, after reading for a week, I understood most of the connection between these classes. However, then I saw more classes, and then more classes—I got lost in the sauce. To understand it, I had to learn C++ first. I'm used to writing in TypeScript, so I learned it and implemented the socket in CConnman. After setting up a basic relation where a CNode is created for every incoming connection, I have an array of CNode to keep track of the nodes I'm connected to. But after that, I got lost again. Any suggestions would be appreciated.

**Tags:** bitcoin-core-development, nodes, p2p, javascript, connection


---

## 1 answers

### Answer by username_1 on 2024-09-03. Score: 1

Bitcoin Core’s connection management is probably much more complicated than what you are looking to do. You may want to look into the actual message flow that nodes adhere to for the peer-to-peer protocol and create a very simple implementation of that. You can for example have a look at the Bitcoin Developer Guide’s [P2P Network section](https://developer.bitcoin.org/devguide/p2p_network.html). There are also several libraries that implement parts of the peer-to-peer protocol in TypeScript and JavaScript which may be more accessible for you to read. You could for example have a look at the [`bcoin`](https://github.com/bcoin-org/bcoin) repository to see if that is more accessible.


---

