<p>The "blockchain" is a conceptual structure that is not directly represented in a program. If you were writing a program to work with the blockchain, you get to choose how you would implement it in a data structure.</p>

<ul>
<li>If your data structure is a linked list, you would follow the back link pointer to the previous block</li>
<li>If your data structure is a hash table, you would look up the previous block hash in your table to find the previous block</li>
<li>If your data structure is an array, you would look in the previous array slot to find the previous block</li>
</ul>

<p>As you can see, there are many possible choices one could make when representing the blockchain in memory. This is further complicated by the fact that the blockchain is probably too big to load into memory all at once, so you would probably need to involve some kind of on-disk storage too (a database perhaps).</p>

CC BY-SA 3.0
2014-02-23T17:22:40.237Z
2014-02-23T17:22:40.237Z
Greg Hewgill
<p>I'm thinking (probably erroneously) along the lines of a linked list and C pointers, but how would one follow the block chain from some block all the way back to the genesis block? The previous block's hash is the "pointer", but in a C program (say), given any block how would the previous block be accessed?</p>

<blockchain>
How does one programmatically "walk-back" on the block chain?
ruana
# How does one programmatically "walk-back" on the block chain?

(Asked by: username_0 on 2014-02-23)

I'm thinking (probably erroneously) along the lines of a linked list and C pointers, but how would one follow the block chain from some block all the way back to the genesis block? The previous block's hash is the "pointer", but in a C program (say), given any block how would the previous block be accessed?

**Tags:** blockchain


---

## 1 answers

### Answer by username_1 on 2014-02-23. Score: 1 | Accepted answer

The "blockchain" is a conceptual structure that is not directly represented in a program. If you were writing a program to work with the blockchain, you get to choose how you would implement it in a data structure.

* If your data structure is a linked list, you would follow the back link pointer to the previous block
* If your data structure is a hash table, you would look up the previous block hash in your table to find the previous block
* If your data structure is an array, you would look in the previous array slot to find the previous block

As you can see, there are many possible choices one could make when representing the blockchain in memory. This is further complicated by the fact that the blockchain is probably too big to load into memory all at once, so you would probably need to involve some kind of on-disk storage too (a database perhaps).


---

