> For the complete documentation index, see [llms.txt](https://metchain.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://metchain.gitbook.io/docs/algorithm/algorithm-1.md).

# Algorithm 1

The GHOST backbone protocol, parameterized by the input contribution function I(·) and the reading function R(·). xC is the vector of inputs of all block in chain C.

1. T GenesisBlock . T is a tree.
2. state <- ε
3. round <- 0
4. while True do
5. Tnew <- update(T , blocks found in Receive())
6. C <-˜ GHOST(Tnew)
7. hstate, xi <- I(state, C˜, round, Input(), Receive())
8. Cnew <- pow(x, C˜)
9. if C 6 ˜ = Cnew or T 6= Tnew then
10. T <- update(Tnew, head(Cnew))
11. Broadcast(head(Cnew))
12. end if
13. round <- round + 1
14. if Input() contains Read then
15. write R(xC) to Output()
16. end if
17. end while

### Algorithm 1 Explained:

For completeness' sake, we now go over the remaining steps in the GHOST backbone protocol. Function update (see Algorithm 4) refers to how the block tree is updated. Function pow (see Algorithm 3), which has to do with block mining, is the same as the one described in the Bitcoin Backbone.
