<blockquote>
  <p>When should I use which construct?</p>
</blockquote>

<p>Use PeerGroup, unless you want to connect to a specific Bitcoin node.</p>

<blockquote>
  <p>From the code, it seems that we should only be interested in <code>PeerGroup</code> and not <code>Peer</code>.</p>
</blockquote>

<p><code>PeerGroup</code> will construct <code>Peer</code> objects. It's necessary, even if you don't use it directly.</p>

CC BY-SA 3.0
2014-10-28T16:18:59.580Z
2014-10-28T16:18:59.580Z
Nick ODell
<p>In BitcoinJ, there is <a href="https://code.google.com/p/bitcoinj/source/browse/core/src/main/java/com/google/bitcoin/core/PeerGroup.java" rel="nofollow"><code>PeerGroup</code></a> and <a href="https://code.google.com/p/bitcoinj/source/browse/core/src/main/java/com/google/bitcoin/core/Peer.java" rel="nofollow"><code>Peer</code></a>.</p>

<p>I understand there are differences such as one is related to a group of peers while other is related to a single peer. </p>

<p>When should I use which construct? Are both necessary?</p>

<p>From the code, it seems that we should only be interested in <code>PeerGroup</code> and not <code>Peer</code>. Then whats the purpose of <code>Peer</code>?</p>

<bitcoinj>
In BitcoinJ, what is the purpose of Peer?
Jus12
# In BitcoinJ, what is the purpose of Peer?

(Asked by: username_0 on 2014-10-28)

In BitcoinJ, there is [`PeerGroup`](https://code.google.com/p/bitcoinj/source/browse/core/src/main/java/com/google/bitcoin/core/PeerGroup.java) and [`Peer`](https://code.google.com/p/bitcoinj/source/browse/core/src/main/java/com/google/bitcoin/core/Peer.java).

I understand there are differences such as one is related to a group of peers while other is related to a single peer.

When should I use which construct? Are both necessary?

From the code, it seems that we should only be interested in `PeerGroup` and not `Peer`. Then whats the purpose of `Peer`?

**Tags:** bitcoinj


---

## 1 answers

### Answer by username_1 on 2014-10-28. Score: 1 | Accepted answer

> When should I use which construct?

Use PeerGroup, unless you want to connect to a specific Bitcoin node.

> From the code, it seems that we should only be interested in `PeerGroup` and not `Peer`.

`PeerGroup` will construct `Peer` objects. It's necessary, even if you don't use it directly.


---

