Merge pull request #322 from eatdostacos/master
Some More LBRY.tech Small Changes
This commit is contained in:
commit
d7b71a0d1c
2 changed files with 6 additions and 6 deletions
|
@ -20,14 +20,14 @@ You can read more on it [here](https://en.wikipedia.org/wiki/Trie), but for unde
|
|||
Each block header holds an extra 256 bits value calculated out of the root node of the claim trie at that block height. It's called `nameclaimroot` and is influenced by all children nodes as we will see next. If a blockchain network peer disagrees that a claim name was accepted or who is the winner of each name, its `nameclaimroot` will differ and the block won't form the same chain as the ones that accepted the official rules. This is the same for the traditional Merkle root, which is the root of the [Merkle tree](https://bitcoin.org/en/glossary/merkle-tree), formed by transactions in a block.
|
||||
|
||||
## What's in a leaf?
|
||||
The leaf currently holds the winner of that name. Its formed by the transaction hash, output number of the claim in that transaction and the height it was accepted.
|
||||
The leaf currently holds the winner of that name. It's formed by the transaction hash, output number of the claim in that transaction and the height it was accepted.
|
||||
|
||||
### Generating the leaf hash
|
||||
So, let's suppose that the winner claim of `mindblown` name was made at transaction output `1` of the transaction hash `67ad533eb2676c9d36bfa100092af5358de747e08ef928c0c54a8b3891c2b76b` and included in the Trie at height `102`.
|
||||
1. The transaction hash is converted from [RPC byte order](https://bitcoin.org/en/glossary/rpc-byte-order) to [internal byte order](https://bitcoin.org/en/glossary/internal-byte-order).
|
||||
2. The output number becomes a simple string.
|
||||
3. The height becomes a big endian 64 bits value.
|
||||
4. The node hash is calculated as the double sha-256 hash of the double sha-256 hash of the internal byte order representation of the transaction hash concatenated with the double sha-256 hash of the output number representation concatenated with the double sha-256 hash of the height.
|
||||
4. The node hash is calculated as the double SHA-256 hash of the double SHA-256 hash of the internal byte order representation of the transaction hash concatenated with the double SHA-256 hash of the output number representation concatenated with the double SHA-256 hash of the height.
|
||||
|
||||
This is better represented in the simple python script below:
|
||||
```python
|
||||
|
@ -54,8 +54,8 @@ print("leaf hash is {}".format(hexlify(hash_leaf(tx, nout, at_height)[::-1])))
|
|||
Let's start with a ClaimTrie holding a single claim.
|
||||
The claim is named `mindblown` and was included at block 102 with the same details as the last section. It's actually a real claim as [you can see in the block explorer](https://explorer.lbry.com/blocks/102). This block has the first claim ever, so the ClaimTrie was the simple case being explained in here.
|
||||
We start with the leaf hash:
|
||||
1. Hash the leaf hash using double sha-256.
|
||||
2. For each character of the name (nodes of the trie), the hash of a node is the double sha-256 of the node's character concatenated with the children hash.
|
||||
1. Hash the leaf hash using double SHA-256.
|
||||
2. For each character of the name (nodes of the trie), the hash of a node is the double SHA-256 of the node's character concatenated with the children hash.
|
||||
|
||||
Continuing with the Python script from the last section, this is how to calculate the root of a claim trie holding a single name:
|
||||
```python
|
||||
|
|
|
@ -5,7 +5,7 @@ description: How does the LBRY blockchain achieve consensus? This resource page
|
|||
|
||||
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.
|
||||
|
||||
LBRY has differences in hash function, block targeting, and difficult adjustment.
|
||||
LBRY has differences in hash function, block targeting, and difficulty adjustment.
|
||||
|
||||
### Hash Mechanism
|
||||
|
||||
|
@ -18,4 +18,4 @@ proof = sha256(sha256(left + right)) # concatenate the two halves, and double-s
|
|||
|
||||
### Block Targeting & Difficulty Adjustment
|
||||
|
||||
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).
|
||||
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).
|
||||
|
|
Loading…
Reference in a new issue