<p>The code on that wiki page is how Bitcoin Core constructs block locators, and it's a good method, but the method isn't enforced by the protocol. All you need to do is list a bunch of block hashes that you know about, ordered by descending block height. So in your example your locator could be (2,1,0), (2,1), (1), etc., but not (1, 2).</p>

CC BY-SA 3.0
2014-11-01T01:20:36.713Z
2014-11-01T01:20:36.713Z
theymos
<p>I have to compose a "getblocks" command found in https://en.bitcoin.it/wiki/Protocol_specification#getblocks</p>

<p>The "getblocks" command contains the "block locator hashes". In essence, I inform a remote node of block hashes that I'm aware of already. There is a rule of how to construct the block locator. Except I’ve no idea of what “pushing”, “going back” or “newest back” means. I cannot figure out the order of block hashes in what I call a locatorArray.</p>

<p>Let’s assume I want to advertise three block hashes:</p>

<ul>
<li>Block hash of block number zero.  </li>
<li>Block hash of block number one.  </li>
<li>Block hash of block number two.  </li>
</ul>

<p>Let’s assume I have an array of three elements. For example, I might walk through the array in a for loop as follows:</p>

<pre><code>for ( int i = 0; i &lt; locatorArrayLength; i++ )
{

}
</code></pre>

<p>The block hash of which block number should be in locatorArray[0]?<br>
The block hash of which block number should be in locatorArray[2]?</p>

CC BY-SA 3.0
2014-10-31T17:07:22.683Z
Where did this data come from, the daemon, an API? Some context would be helpful.
morsecoder
CC BY-SA 3.0
2014-10-31T17:12:46.893Z
I don't understand what data you want in locatorArray.
Nick ODell
CC BY-SA 3.0
2014-10-31T17:43:51.723Z
I've made the statement of my problem more lucid.
u2843
CC BY-SA 3.0
2014-10-31T17:54:30.947Z
@u2843 Did you read the snippet of code provided alongside the documentation?
Nick ODell
CC BY-SA 3.0
2014-10-31T18:13:41.603Z
@Nick ODell I didn't read it. I looked at it. I don't know the language it's written in. I've no idea of what's going on in there. I don't need to know the mechanics of the code. All I care about is whether, using my example, the block number zero is in locatorArray[0] and block number two is in locatorArray[2], or block number two is in locatorArray[0] and block number zero is in locatorArray[2].
u2843
<protocol>
What is the order of block hashes in block-locator array?
u2843
# What is the order of block hashes in block-locator array?

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

I have to compose a "getblocks" command found in https://en.bitcoin.it/wiki/Protocol_specification#getblocks
The "getblocks" command contains the "block locator hashes". In essence, I inform a remote node of block hashes that I'm aware of already. There is a rule of how to construct the block locator. Except I’ve no idea of what “pushing”, “going back” or “newest back” means. I cannot figure out the order of block hashes in what I call a locatorArray.
Let’s assume I want to advertise three block hashes:

Block hash of block number zero.  
Block hash of block number one.  
Block hash of block number two.  

Let’s assume I have an array of three elements. For example, I might walk through the array in a for loop as follows:
for ( int i = 0; i < locatorArrayLength; i++ )
{

}

The block hash of which block number should be in locatorArray[0]?
The block hash of which block number should be in locatorArray[2]?

**Tags:** protocol

> **Comments:**
> **username_1**: Where did this data come from, the daemon, an API? Some context would be helpful.  
> **username_2**: I don't understand what data you want in locatorArray.  
> **username_0**: I've made the statement of my problem more lucid.  
> **username_2**: @username_0 Did you read the snippet of code provided alongside the documentation?  
> **username_0**: @username_2 I didn't read it. I looked at it. I don't know the language it's written in. I've no idea of what's going on in there. I don't need to know the mechanics of the code. All I care about is whether, using my example, the block number zero is in locatorArray[0] and block number two is in locatorArray[2], or block number two is in locatorArray[0] and block number zero is in locatorArray[2].  

---

## 1 answers

### Answer by username_3 on 2014-11-01. Score: 1

The code on that wiki page is how Bitcoin Core constructs block locators, and it's a good method, but the method isn't enforced by the protocol. All you need to do is list a bunch of block hashes that you know about, ordered by descending block height. So in your example your locator could be (2,1,0), (2,1), (1), etc., but not (1, 2).


---

