2019-02-15 11:50:56 -05:00
|
|
|
---
|
|
|
|
title: Consensus Algorithm
|
|
|
|
description: How does the LBRY blockchain achieve consensus? This resource page will explain.
|
|
|
|
---
|
2018-07-13 13:03:21 -05:00
|
|
|
|
2019-02-19 13:11:46 -05:00
|
|
|
LBRY uses [proof of work](https://en.bitcoin.it/wiki/Proof_of_work) as a [consensus mechanism](/spec#consensus), the same way that Bitcoin does.
|
2018-07-13 13:03:21 -05:00
|
|
|
|
2020-05-01 10:09:21 -07:00
|
|
|
LBRY has differences in hash function, block targeting, and difficulty adjustment.
|
2018-09-30 13:34:29 -04:00
|
|
|
|
|
|
|
### Hash Mechanism
|
2018-07-13 13:03:21 -05:00
|
|
|
|
|
|
|
```python
|
|
|
|
intermediate = sha512(sha256(sha256(data))) # compute the sha512() of the double-sha256() of the data
|
|
|
|
left = ripemd(intermediate[:len(intermediate)/2]) # separately ripemd160 the left half
|
|
|
|
right = ripemd(intermediate[len(intermediate)/2:]) # and the right half
|
|
|
|
proof = sha256(sha256(left + right)) # concatenate the two halves, and double-sha256() it again
|
|
|
|
```
|
|
|
|
|
2019-01-12 11:34:10 -08:00
|
|
|
### Block Targeting & Difficulty Adjustment
|
2018-07-13 13:03:21 -05:00
|
|
|
|
2020-05-01 10:09:21 -07:00
|
|
|
The targeted time of each LBRY block is 2.5 mintues (150 seconds). More information and links to source code [here](https://lbry.tech/spec#consensus).
|