<p>Michael's answer was very helpful for me, but I think it is also helpful to take a look at the source code and implementation of <code>inv</code> messages while the question is tagged <code>bitcoin-core-development</code>.</p>
<p>This is the source code for <code>inv</code> messages. <a href="https://github.com/bitcoin/bitcoin/blob/master/src/protocol.h#L471" rel="nofollow noreferrer">Link</a>:</p>
<pre><code>/** inv message data */
class CInv
{
public:
    CInv();
    CInv(uint32_t typeIn, const uint256&amp; hashIn);

    SERIALIZE_METHODS(CInv, obj) { READWRITE(obj.type, obj.hash); }

    friend bool operator&lt;(const CInv&amp; a, const CInv&amp; b);

    std::string GetCommand() const;
    std::string ToString() const;

    // Single-message helper methods
    bool IsMsgTx() const { return type == MSG_TX; }
    bool IsMsgBlk() const { return type == MSG_BLOCK; }
    bool IsMsgWtx() const { return type == MSG_WTX; }
    bool IsMsgFilteredBlk() const { return type == MSG_FILTERED_BLOCK; }
    bool IsMsgCmpctBlk() const { return type == MSG_CMPCT_BLOCK; }
    bool IsMsgWitnessBlk() const { return type == MSG_WITNESS_BLOCK; }

    // Combined-message helper methods
    bool IsGenTxMsg() const
    {
        return type == MSG_TX || type == MSG_WTX || type == MSG_WITNESS_TX;
    }
    bool IsGenBlkMsg() const
    {
        return type == MSG_BLOCK || type == MSG_FILTERED_BLOCK || type == MSG_CMPCT_BLOCK || type == MSG_WITNESS_BLOCK;
    }

    uint32_t type;
    uint256 hash;
};
</code></pre>

CC BY-SA 4.0
2022-08-09T16:34:03.537Z
2022-08-09T17:29:48.747Z
2022-08-09T17:29:48.747Z
Amir reza Riahi
<p><code>inv</code> is short for inventory. As the Bitcoin <a href="https://en.bitcoin.it/wiki/Protocol_documentation#Inventory_Vectors" rel="nofollow noreferrer">wiki</a> says:</p>
<blockquote>
<p>Inventory vectors are used for notifying other nodes about objects they have or data which is being requested.</p>
</blockquote>
<p>Inventory vectors consist of the following data format:</p>
<p><a href="https://i.sstatic.net/gVLyq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gVLyq.png" alt="enter image description here" /></a></p>
<p>The <code>inv</code> message (for transactions) was explained in the <a href="https://bitcoincore.reviews/21224" rel="nofollow noreferrer">notes</a> of this PR review club in Feb 2021 hosted by Elle Mouton.</p>
<blockquote>
<p>Transaction relay is a three step process: <code>inv</code> -&gt; <code>getdata</code> -&gt; <code>tx</code>:</p>
<ol>
<li>the relaying node sends an <code>inv</code> message to the receiving node to announce a new transaction.</li>
<li>if the receiving node wants to retrieve the transaction that it learned about in the <code>inv</code> message then it will send a <code>getdata</code> message to the relaying node to request the full transaction. (The receiving node won't send a <code>getdata</code> message to a peer for transactions that it has already seen or if it has already sent a <code>getdata</code> message for the transaction to a different peer.)</li>
<li>the relaying node delivers a <code>tx</code> message to the receiving node. If the relaying node is no longer able to deliver the transaction, it responds with <code>notfound</code> instead of the <code>tx</code>.</li>
</ol>
</blockquote>

CC BY-SA 4.0
2022-08-08T17:38:20.510Z
2022-08-08T17:38:20.510Z
Michael Folkson
<p>I was reviewing the <a href="https://github.com/bitcoin/bitcoin/pull/25720" rel="nofollow noreferrer">PR #25720</a>. This is part of description for the PR:</p>
<blockquote>
<p>However, if an INV for a block is received before our headers chain is
caught up, we'll then start to sync headers from each peer announcing
the block. This can result in doing a big headers sync with many (if
not all) of our peers simultaneously, which wastes bandwidth.</p>
</blockquote>
<p>What is an <code>INV</code> message? I tried to figure it out by searching it but found nothing useful. This <a href="https://en.bitcoin.it/wiki/Protocol_documentation#inv" rel="nofollow noreferrer">link</a> had a small information about it but it is still not clear for me what it is.</p>

<bitcoin-core-development><protocol><p2p><message>
What is an inv message?
Amir reza Riahi
# What is an inv message?

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

I was reviewing the [PR #25720](https://github.com/bitcoin/bitcoin/pull/25720). This is part of description for the PR:

> However, if an INV for a block is received before our headers chain is
> caught up, we'll then start to sync headers from each peer announcing
> the block. This can result in doing a big headers sync with many (if
> not all) of our peers simultaneously, which wastes bandwidth.

What is an `INV` message? I tried to figure it out by searching it but found nothing useful. This [link](https://en.bitcoin.it/wiki/Protocol_documentation#inv) had a small information about it but it is still not clear for me what it is.

**Tags:** bitcoin-core-development, protocol, p2p, message


---

## 2 answers

### Answer by username_1 on 2022-08-08. Score: 4 | Accepted answer

`inv` is short for inventory. As the Bitcoin [wiki](https://en.bitcoin.it/wiki/Protocol_documentation#Inventory_Vectors) says:

> Inventory vectors are used for notifying other nodes about objects they have or data which is being requested.

Inventory vectors consist of the following data format:

[![enter image description here](https://i.sstatic.net/gVLyq.png)](https://i.sstatic.net/gVLyq.png)

The `inv` message (for transactions) was explained in the [notes](https://bitcoincore.reviews/21224) of this PR review club in Feb 2021 hosted by Elle Mouton.

> Transaction relay is a three step process: `inv` -> `getdata` -> `tx`:
>
> 1. the relaying node sends an `inv` message to the receiving node to announce a new transaction.
> 2. if the receiving node wants to retrieve the transaction that it learned about in the `inv` message then it will send a `getdata` message to the relaying node to request the full transaction. (The receiving node won't send a `getdata` message to a peer for transactions that it has already seen or if it has already sent a `getdata` message for the transaction to a different peer.)
> 3. the relaying node delivers a `tx` message to the receiving node. If the relaying node is no longer able to deliver the transaction, it responds with `notfound` instead of the `tx`.


---

### Answer by username_0 on 2022-08-09. Score: 1

username_1's answer was very helpful for me, but I think it is also helpful to take a look at the source code and implementation of `inv` messages while the question is tagged `bitcoin-core-development`.

This is the source code for `inv` messages. [Link](https://github.com/bitcoin/bitcoin/blob/master/src/protocol.h#L471):

```
/** inv message data */
class CInv
{
public:
    CInv();
    CInv(uint32_t typeIn, const uint256& hashIn);

    SERIALIZE_METHODS(CInv, obj) { READWRITE(obj.type, obj.hash); }

    friend bool operator<(const CInv& a, const CInv& b);

    std::string GetCommand() const;
    std::string ToString() const;

    // Single-message helper methods
    bool IsMsgTx() const { return type == MSG_TX; }
    bool IsMsgBlk() const { return type == MSG_BLOCK; }
    bool IsMsgWtx() const { return type == MSG_WTX; }
    bool IsMsgFilteredBlk() const { return type == MSG_FILTERED_BLOCK; }
    bool IsMsgCmpctBlk() const { return type == MSG_CMPCT_BLOCK; }
    bool IsMsgWitnessBlk() const { return type == MSG_WITNESS_BLOCK; }

    // Combined-message helper methods
    bool IsGenTxMsg() const
    {
        return type == MSG_TX || type == MSG_WTX || type == MSG_WITNESS_TX;
    }
    bool IsGenBlkMsg() const
    {
        return type == MSG_BLOCK || type == MSG_FILTERED_BLOCK || type == MSG_CMPCT_BLOCK || type == MSG_WITNESS_BLOCK;
    }

    uint32_t type;
    uint256 hash;
};

```


---

