<p>In brief you would use your Bitcoin libraries functions to perform peer discovery and then periodically communicate with a few peers to collect data.</p>
<p>Your question isn't an exact duplicate of any question I can find but existing answers to the following questions will help:</p>
<ul>
<li><a href="https://bitcoin.stackexchange.com/q/106131/13866">How transaction happen in blockchain?</a></li>
<li><a href="https://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other">How do Bitcoin clients find each other?</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/32237/13866">How are transactions broadcast to the rest of the network?</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/70621/13866">How does a node get information from other nodes?</a></li>
</ul>
<hr />
<p>Other useful resources</p>
<ul>
<li><a href="https://en.bitcoin.it/wiki/Protocol_documentation" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Protocol_documentation</a></li>
<li><a href="https://developer.bitcoin.org/devguide/p2p_network.html" rel="nofollow noreferrer">https://developer.bitcoin.org/devguide/p2p_network.html</a><br />
This covers the following topics
<ul>
<li>Peer discovery</li>
<li>Connecting to peers</li>
<li>Initial Block download</li>
<li>Block broadcasting</li>
<li>Transaction broadcasting<br />
This is the part where your node listens for <code>inv</code> messages
and issues corresponding messages such as <code>getdata</code>.</li>
</ul>
</li>
</ul>

CC BY-SA 4.0
2022-02-10T11:54:23.677Z
2022-02-10T12:07:53.310Z
2022-02-10T12:07:53.310Z
RedGrittyBrick
<p>I'm taking up a project to build a software in python to mine cryptocurrency (preferably bitcoin).
I have an overview of the computation that needs to be done.</p>
<p>I would like to know how nodes fetch unconfirmed transactions.</p>

CC BY-SA 4.0
2022-02-08T16:53:51.500Z
I think that's too big a question to be answerable here. You could break your question down into much smaller parts and research those separately and ask questions here about specific individual points. See [what is mining](https://bitcoin.stackexchange.com/q/148/13866) etc.
RedGrittyBrick
CC BY-SA 4.0
2022-02-10T11:19:49.840Z
@RedGrittyBrick Thanks!
Sarath Jyothis
CC BY-SA 4.0
2022-02-10T11:24:37.013Z
So, there are three sub problems to focus on here: 1.) Fetching unconfirmed transactions 2.) Finding the nonce for hashing based on the difficulty and creating a new block 3.) Submitting/broadcasting the new block to the network for verification. I'm stuck at subproblem 1 and 3 from a programming point of view.
Sarath Jyothis
CC BY-SA 4.0
2022-02-10T11:49:40.420Z
You seem to be struggling a little. I will edit your question for you -- though you can do this yourself. If you don't like my edits you can use the "rollback" option under "edit".
RedGrittyBrick
CC BY-SA 4.0
2022-02-18T08:18:24.190Z
Thanks @RedGrittyBrick for making the question more appropriate. I'm gathering a lot of info from the materials provided.
Sarath Jyothis
<blockchain><python><cryptography><mining-software>
How do nodes fetch unconfirmed transactions?
Sarath Jyothis
# How do nodes fetch unconfirmed transactions?

(Asked by: username_0 on 2022-02-08)

I'm taking up a project to build a software in python to mine cryptocurrency (preferably bitcoin).
I have an overview of the computation that needs to be done.

I would like to know how nodes fetch unconfirmed transactions.

**Tags:** blockchain, python, cryptography, mining-software

> **Comments:**
> **username_1**: I think that's too big a question to be answerable here. You could break your question down into much smaller parts and research those separately and ask questions here about specific individual points. See [what is mining](https://bitcoin.stackexchange.com/q/148/13866) etc.  
> **username_0**: @username_1 Thanks!  
> **username_0**: So, there are three sub problems to focus on here: 1.) Fetching unconfirmed transactions 2.) Finding the nonce for hashing based on the difficulty and creating a new block 3.) Submitting/broadcasting the new block to the network for verification. I'm stuck at subproblem 1 and 3 from a programming point of view.  
> **username_1**: You seem to be struggling a little. I will edit your question for you -- though you can do this yourself. If you don't like my edits you can use the "rollback" option under "edit".  
> **username_0**: Thanks @username_1 for making the question more appropriate. I'm gathering a lot of info from the materials provided.  

---

## 1 answers

### Answer by username_1 on 2022-02-10. Score: 0

In brief you would use your Bitcoin libraries functions to perform peer discovery and then periodically communicate with a few peers to collect data.

Your question isn't an exact duplicate of any question I can find but existing answers to the following questions will help:

* [How transaction happen in blockchain?](https://bitcoin.stackexchange.com/q/106131/13866)
* [How do Bitcoin clients find each other?](https://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other)
* [How are transactions broadcast to the rest of the network?](https://bitcoin.stackexchange.com/q/32237/13866)
* [How does a node get information from other nodes?](https://bitcoin.stackexchange.com/q/70621/13866)

---

Other useful resources

* <https://en.bitcoin.it/wiki/Protocol_documentation>
* <https://developer.bitcoin.org/devguide/p2p_network.html>  
  This covers the following topics
  + Peer discovery
  + Connecting to peers
  + Initial Block download
  + Block broadcasting
  + Transaction broadcasting  
    This is the part where your node listens for `inv` messages
    and issues corresponding messages such as `getdata`.


---

